#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
long long n, k, ans = 0;
int arr[100010][4], brr[100010][4];
string str[1000010];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  char ch;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n / 4; j++) {
      cin >> ch;
      int m;
      if (ch <= '9' && ch >= '0') {
        m = ch - '0';
      } else
        m = ch - 'A' + 10;
      string s = "";
      for (int k = 3; k >= 0; k--) {
        if (m % 2 == 0)
          str[i] += '0';
        else
          str[i] += '1';
        m = m / 2;
      }
      for (int k = 3; k >= 0; k--) {
        str[i] += s[k];
      }
    }
  }
  int ans = 1;
  for (int z = 2; z <= n; z++) {
    if (n == 5040) cout << z << endl;
    int f = 0;
    if (n % z != 0) continue;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (str[i][j] != str[i / z * z][j / z * z]) {
          f = 1;
          break;
        }
      }
      if (f == 1) break;
    }
    if (f == 0) ans = z;
  }
  cout << ans << endl;
  return 0;
}
