Bob lived on an island which has many kinds of beautiful seashells. We can regard this island as a rectangular grid that is n rows by m columns. Assume that the coordinates of the j-th column of the i-th row is (i, j). The coordinates of Bob's house is (x, y). There is at most one kind of seashells in each cell. Bob likes collecting seashells very much. However, he can only go the place of coordinates (x0, y0) with |x0-x|+|y0-y|<=A and max(|x0-x|, |y0-y|) <= B. How many kinds of seashells can Bob get at most?