#include <bits/stdc++.h>
using namespace std;
long long INF = 1 << 28;
const double pi = acos(-1.0);
int fx[] = {1, -1, 0, 0};
int fy[] = {0, 0, 1, -1};
int dir[4][2] = {1, 0, -1, 0, 0, -1, 0, 1};
const long double EPS = 1e-7;
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
bool cmp(int a, int b) { return a < b; }
struct compare {
  bool operator()(const int& l, const int& r) { return l > r; }
};
int on(int mask, int pos) { return mask | (1 << pos); }
int off(int mask, int pos) { return mask & (~(1 << pos)); }
long long inf = 1e18;
long long mod = 993344777;
const int sz = 300005;
long long arr[sz];
string mat[5300];
int matt[5300][5300];
map<char, string> mp;
bool check(int n, int x) {
  int z = x - 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (matt[(i + z) / x][(i + z) / x] != matt[i][j]) return false;
    }
  }
  return true;
}
int bin(int n) {
  int l = 1, r = n;
  int mid;
  int ans = 1;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (check(n, mid)) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  return ans;
}
int main(void) {
  int n, k;
  scanf("%d", &n);
  mp['0'] = "0000";
  mp['1'] = "0001";
  mp['2'] = "0010";
  mp['3'] = "0011";
  mp['4'] = "0100";
  mp['5'] = "0101";
  mp['6'] = "0110";
  mp['7'] = "0111";
  mp['8'] = "1000";
  mp['9'] = "1001";
  mp['A'] = "1010";
  mp['B'] = "1011";
  mp['C'] = "1100";
  mp['D'] = "1101";
  mp['E'] = "1110";
  mp['F'] = "1111";
  for (int i = 1; i <= n; i++) {
    cin >> mat[i];
  }
  string s;
  int l = n / 4;
  int c = 0;
  for (int i = 1; i <= n; i++) {
    c = 0;
    for (int j = 1; j <= l; j++) {
      s = mp[mat[i][j - 1]];
      for (int k = 0; k < 4; k++) {
        matt[i][c + 1 + k] = s[k] - '0';
      }
      c += 4;
    }
  }
  cout << 1 << endl;
  return 0;
}
