#include <bits/stdc++.h>
using namespace std;
const char str[] = "0123456789ABCDEF";
bool a[5500][5500];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int k = 0; k < n / 4; k++) {
      int u = strchr(str, s[k]) - str;
      for (int j = 0; j < 4; j++) a[i][k * 4 + j] = u >> (3 - j) & 1;
    }
  }
  for (int x = n; x >= 1; x--)
    if (n % x == 0) {
      int m = n / x;
      bool flg = 1;
      for (int i = 0; flg && i < n; i++) {
        for (int j = 0; flg && j < n; j++) {
          flg &= (a[i][j] == a[i / m * m][j / m * m]);
        }
      }
      if (flg) {
        cout << x << endl;
        return 0;
      }
    }
  return 0;
}
