You need to find the Greatest Common Divisor.(GCD) or also called Greatest Common Factor.
Factors of 27 = 1, 3, 9, 27
Factors of 36 = 1, 2, 3, 4, 6, 9, 12, 18, 36
Above we can see that 9 is the greatest number each has in common so
The GCD = 9
So the greatest number of boxes the baker can make using all of the bagels is 9