#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("expensive-optimizations")
using namespace std;
constexpr short int infs = 3e4 + 7;
constexpr int inf = 1e9 + 7;
constexpr long long infl = 1e18 + 7;
bool t[5207][5207];
bool ok(int x, int y, int k) {
  for (int i = x; i < x + k; i++)
    for (int j = y; j < y + k; j++)
      if (t[i][j] != t[x][y]) return true;
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  int n, a, x, xd = 1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    x = 1;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] >= '0' && s[j] <= '9')
        a = s[j] - '0';
      else
        a = s[j] - 'A' + 10;
      for (int k = 0; k <= 3; k++) {
        if (a & (1 << k)) t[i][x] = 1;
        x++;
      }
    }
  }
  for (int i = 2; i <= n; i++) {
    if (n % i) continue;
    for (int j = 1; j <= n; j += i)
      for (int k = 1; k <= n; k += i)
        if (ok(j, k, i)) goto XD;
    xd = i;
  XD:;
  }
  cout << xd;
  return 0;
}
