#include <bits/stdc++.h>
using namespace std;
int eq(char c) {
  if (c >= '0' and c <= '9')
    return c - '0';
  else
    return c - 'A' + 10;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n, ss;
  cin >> n;
  string s[n];
  bitset<5201> b[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    int k = 0;
    for (auto j : s[i]) {
      int l = eq(j);
      b[i][k + 3] = l % 2;
      l /= 2;
      b[i][k + 2] = l % 2;
      l /= 2;
      b[i][k + 1] = l % 2;
      l /= 2;
      b[i][k] = l % 2;
      l /= 2;
      k += 4;
    }
  }
  map<int, int> mp;
  mp[1] = 1;
  for (int i = n; i >= 2; i--) {
    if (n % i != 0) continue;
    if (mp[i]) continue;
    int f = 1;
    for (int r = 0; r < n; r++) {
      for (int c = 0; c <= n - i; c += i) {
        for (int e = c; e < c + i; e++) {
          if (b[r][e] != b[r][c]) {
            f = 0;
            break;
          }
        }
        if (!f) break;
      }
      if (!f) break;
    }
    if (f) {
      int srt = sqrt(i);
      for (int x = 1; x <= srt; x++) {
        if (i % x == 0) {
          if (x * x == i)
            mp[x] = 1;
          else
            mp[x] = 1, mp[i / x] = 1;
        }
      }
    }
  }
  vector<int> v;
  for (auto i : mp)
    if (i.second) v.push_back(i.first);
  reverse(v.begin(), v.end());
  ss = s[0].size();
  for (auto i : v) {
    int f = 1;
    for (int c = 0; c < ss; c++) {
      for (int r = 0; r <= n - i; r += i) {
        for (int e = r; e < r + i; e++) {
          if (b[e][c] != b[r][c]) {
            f = 0;
            break;
          }
        }
        if (!f) break;
      }
      if (!f) break;
    }
    if (f) {
      cout << i;
      return 0;
    }
  }
  cout << 1;
}
