Let x = number of beans with Martha Let y = number of beans with Mary
Since total beans is 375, x + y = 375
Mary ate 24 beans, after this she must be having x - 24 beans Similarly after eating 1/7y beans, mary must be having y - y/7 beans Setting them equal to each other x - 24 = y - y/7