import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

import static java.lang.Integer.parseInt;

public class Main {
    public static void main(String[] args) throws IOException {

        PrintWriter out = new PrintWriter(System.out);
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter printWriter = new PrintWriter(System.out);

        int n = parseInt(in.readLine());

        int[][] А = new int[n][n];
        int[] X = new int[n];
        int[] Y = new int[n];

        StringBuilder stringBuilder = new StringBuilder();

        for (int i = 0; i < n; i++) {
            int j = 0;
            for (char c : in.readLine().toCharArray()) {

                int z = Character.digit(c, 16);

                //System.out.println(Integer.toBinaryString(z));

                String s = Integer.toBinaryString(z);

                StringBuilder stringBuilder1 = new StringBuilder(s);
                if (s.length() == 3) {
                    stringBuilder1.insert(0, "0");
                } else if (s.length() == 2) {
                    stringBuilder1.insert(0, "00");
                } else if (s.length() == 1) {
                    stringBuilder1.insert(0, "000");
                }

                for (char ch : stringBuilder1.toString().toCharArray()) {
                    А[i][j] = Character.digit(ch, 10);
                    X[i] = X[i] + А[i][j];
                    Y[j] = Y[j] + А[i][j];
                    j++;
                }
            }
        }

        int result = 1;
        for (int period = 1; period <= n/2; period++) {

            if (n % period== 0) {

                boolean ok = true;

                for (int indexStart = 0; indexStart < n; indexStart++) {

                    int valueX = X[indexStart];
                    int valueY = Y[indexStart];

                    for (int index = indexStart + period; index < n; index = index + period) {
                        if ((valueX != X[index]) || (valueY != Y[index])) {
                            ok = false;
                            break;
                        }
                    }

                    if (!ok){
                        break;
                    }

                }

                if (ok) {
                    result = n/period;
                    break;
                }

            }
        }

        System.out.println(result);
    }
}