#include <bits/stdc++.h>
using namespace std;
map<char, string> we;
int n, x;
string ar[5202];
int pass(int b) {
  int f = 0, d = n / b;
  for (int k = 0; k < d; k++) {
    char c = ar[b * k][b * k], cc;
    for (int i = 0; i < b; i++) {
      for (int j = 0; j < b; j++) {
        cc = ar[b * k + i][b * k + j];
        if (cc != c) {
          f = 1;
          break;
        }
      }
      if (f == 1) break;
    }
    if (f == 1) break;
  }
  return f;
}
int main() {
  we['0'] = "0000";
  we['1'] = "0001";
  we['2'] = "0010";
  we['3'] = "0011";
  we['4'] = "0100";
  we['5'] = "0101";
  we['6'] = "0110";
  we['7'] = "0111";
  we['8'] = "1000";
  we['9'] = "1001";
  we['A'] = "1010";
  we['B'] = "1011";
  we['C'] = "1100";
  we['D'] = "1101";
  we['E'] = "1110";
  we['F'] = "1111";
  scanf("%d", &n);
  x = n / 4;
  char c;
  for (int i = 0; i < n; i++) {
    scanf("%c", &c);
    string s;
    for (int j = 0; j < x; j++) {
      scanf("%c", &c);
      s += we[c];
    }
    ar[i] = s;
  }
  int cnt = 1;
  while (pass(cnt) == 0 && cnt <= n) {
    cnt = cnt * 2;
  }
  cnt = cnt / 2;
  printf("%d", cnt);
  return 0;
}
