Rabbits are naturally curious creatures, and they enjoy exploring geometry by running around planting beds. Our rabbit is no exception. Today, he has decided to investigate a new shape—a square.
The rabbit is running around a planting bed, which is a checkered field consisting of N \times M cells. Some of these cells have carrots planted in them, while others do not.
Your task is to help the rabbit determine the side length of the largest square that is completely filled with carrots.
The first line contains two natural numbers and (1 \leq N, M \leq 1000). Then follow lines, each containing numbers separated by spaces. Each number is if the cell does not contain a carrot, or if it does.
Output a single number—the side length of the largest square filled entirely with carrots.
Example 1