#include <bits/stdc++.h>
using namespace std;
const int N = 5200 + 43;
bool a[N][N];
int fact[N];
bool f(int n, int k) {
  int up = 10000;
  for (int i = 0; i < up; i++) {
    int x = rand() % n;
    int y = rand() % n;
    if (a[x][y] != a[x / k * k][y / k * k]) return false;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  string s;
  srand(time(NULL));
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < n / 4; j++) {
      int x = s[j];
      if (s[j] >= 'A')
        x = s[j] - 'A' + 10;
      else
        x = s[j] - '0';
      for (int k = j * 4 + 3; k >= j * 4; k--) a[i][k] = x & 1, x >>= 1;
    }
  }
  int k = 0;
  for (int i = 1; i * i <= n; i++)
    if (n % i == 0) {
      fact[k++] = i;
      if (i * i != n) fact[k++] = n / i;
    }
  sort(fact, fact + k);
  int l = 0, r = k - 1, mid;
  for (mid = r; mid >= l; mid--) {
    if (f(n, fact[mid])) {
      cout << fact[mid] << endl;
      break;
    }
  }
}
