John uses a cutter to cut a rectangle of size MxN (N, M integer ≤ 5000) into a number of at least square dimensions of positive integers and have sides parallel to the original rectangular edge. The cutting cutter always cuts in parallel with one of the two sides of the rectangle and divides the rectangle into two parts. Calculate the number of squares created.
For example, with M = 5 and N = 6, the minimum number of squares that can be generated is 5.