import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;

public class ProblemD {
    public static void main(String args[])throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        byte A[][] = new byte[n][n];
        for(int i=0;i<n;i++)
        {
            String line=br.readLine();
            String booleanLine=new BigInteger(line,16).toString(2);
            //System.out.println(booleanLine);
            for(int j=0;j<booleanLine.length();j++)
                A[i][(n-1)-j]=Byte.parseByte(String.valueOf(booleanLine.charAt(booleanLine.length()-1-j)));
            for(int j=0;j<n-booleanLine.length();j++)
                A[i][j]=0;
        }
        System.out.println("Wrong answer");
        /*for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
                System.out.print(A[i][j]);
            System.out.println();
        }*/
        ArrayList<Integer> factors = new ArrayList<>();
        for(int i=2;i<=n/2;i++)
        {
            if(n%i==0)
                factors.add(i);
        }
        factors.add(n);
        /*for(int x=0;x<factors.size();x++)
            System.out.println(factors.get(x));*/
        boolean isPossible;
        int maxCompFact=1,blockVal;
        for(int x=0;x<factors.size();x++)
        {
            int currentFactor=factors.get(x);
            isPossible=true;
            outer:for(int i=0;i<n/currentFactor;i++)
            {
                for(int j=0;j<n/currentFactor;j++)
                {
                    blockVal=A[i*currentFactor][j*currentFactor];
                    for(int alt_i=0;alt_i<currentFactor;alt_i++)
                    {
                        for(int alt_j=1;alt_j<currentFactor;alt_j++)
                        {
                            if(A[(i*currentFactor)+alt_i][(j*currentFactor)+alt_j]!=blockVal)
                            {
                                isPossible=false;
                                break outer;
                            }
                        }
                    }
                }
            }
            if(isPossible)
                maxCompFact=currentFactor;
            else
                break;
        }
        System.out.println(maxCompFact);
    }
}