#include <bits/stdc++.h>
using namespace std;
void print(vector<int> v) {
  for (int i = 0; i < (v.size()); i++) cout << v[i] << " ";
  cout << endl;
}
map<char, string> conv;
map<string, int> mem;
int check2(string s, int n) {
  string ss = "";
  for (int i = 0; i < (s.size()); i++) ss += conv[s[i]];
  int check = 1;
  for (int i = 0; i < (ss.size()); i++) {
    if (ss[(i / n) * n] != ss[i]) return 0;
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  conv['0'] = "0000";
  conv['1'] = "0001";
  conv['2'] = "0010";
  conv['3'] = "0011";
  conv['4'] = "0100";
  conv['5'] = "0101";
  conv['6'] = "0110";
  conv['7'] = "0111";
  conv['8'] = "1000";
  conv['9'] = "1001";
  conv['A'] = "1010";
  conv['B'] = "1011";
  conv['C'] = "1100";
  conv['D'] = "1101";
  conv['E'] = "1110";
  conv['F'] = "1111";
  int n;
  scanf("%d", &(n));
  string second[n];
  for (int i = 0; i < (n); i++) cin >> second[i];
  int check, ch, c2;
  int ans = 1;
  for (int c3 = n; c3 > 1; c3--)
    if (n % c3 == 0) {
      ch = n / c3;
      check = 1;
      for (int i = 0; i < (n); i++) {
        if (second[(i / c3) * c3] != second[i]) {
          check = 0;
          break;
        }
      }
      c2 = 0;
      if (check) {
        c2 = 1;
        for (int i = 0; i < (n / c3); i++)
          if (!check2(second[i * c3], c3)) {
            c2 = 0;
            break;
          }
      }
      if (c2) ans = c3;
      break;
    }
  cout << ans << endl;
  return 0;
}
