import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.ni();
            int div = 2;
            ArrayList<Integer> divs = new ArrayList<>();
            divs.add(n);
            for (; div * div < n; div++) {
                if (n % div == 0) {
                    divs.add(div);
                    divs.add(n / div);
                }
            }
            if (div * div == n)
                divs.add(div);

            BigInteger[] bis = new BigInteger[n];

            for (int i = 0; i < n; i++) {
                String s = in.ns();
                bis[i] = new BigInteger(s, 16);
            }
            String top = bis[0].toString(2);
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < n - top.length(); i++) {
                sb.append('0');
            }
            sb.append(top);
            top = sb.toString();
            int ans = 1;
            for (int x : divs) {
                boolean correct = true;
                for (int i = 0; i < n / x && correct; i++) {
                    if (i != 0) {
                        if (top.charAt(i * x) == top.charAt(i * x - 1)) {
                            correct = false;
                            break;
                        }
                    }
                    for (int j = 1; j < x; j++) {
                        if (top.charAt(i * x + j) != top.charAt(i * x + j - 1)) {
                            correct = false;
                            break;
                        }
                    }
                }
                BigInteger MASK = BigInteger.valueOf(2).pow(n).subtract(BigInteger.ONE);
                if (correct) {
                    for (int i = 0; i < n / x && correct; i++) {
                        if (i != 0) {
                            if (!bis[i * x].xor(MASK).equals(bis[i * x - 1])) {
                                correct = false;
                                break;
                            }
                        }
                        for (int j = 1; j < x; j++) {
                            if (!bis[i * x + j].equals(bis[i * x + j - 1])) {
                                correct = false;
                                break;
                            }
                        }
                    }
                }
                if (correct)
                    ans = Math.max(ans, x);
            }
            out.println(ans);


        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

    }
}

