using System;

class Program
{
    static void Main(string[] args)
    {
        int n, m;
        string[] linija = Console.ReadLine().Split(' ');
        n = int.Parse(linija[0]); m = int.Parse(linija[1]);
        char[,] mat = new char[n,m];
        string l;
        for (int i = 0; i < n; i++)
        {
            l = Console.ReadLine();
            for (int j = 0; j < m; j++)
            {
                mat[i,j] = l[j];
            }
        }
        Console.WriteLine((int)Math.Sqrt(n*m));
    }
}