#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
const long long maxn = 1000001, mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  map<char, string> con;
  string s[n];
  for (long long i = 0; i < (long long)(n); ++i) {
    cin >> s[i];
  }
  for (long long i = (long long)(0); i <= (long long)(15); ++i) {
    int n = i;
    string s;
    while (n) {
      if (n & 1)
        s += '1';
      else
        s += '0';
      n >>= 1;
    }
    while (s.size() != 4) {
      s += '0';
    }
    reverse((s).begin(), (s).end());
    if (i < 10)
      con[i + '0'] = s;
    else {
      if (i == 10) con['A'] = s;
      if (i == 11) con['B'] = s;
      if (i == 12) con['C'] = s;
      if (i == 13) con['D'] = s;
      if (i == 14) con['E'] = s;
      if (i == 15) con['F'] = s;
    }
  }
  set<int> d;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      d.insert(i);
      d.insert(n / i);
    }
  }
  int ans = 1;
  for (auto it : d) {
    if (it == n) continue;
    if (it == 1) continue;
    for (int i = 0; i < n; i += it) {
      string tempp;
      for (auto ii : s[i]) {
        tempp += con[ii];
      }
      bool flag = true;
      for (int k = 0; k < tempp.size(); k++) {
        int tt = it;
        set<char> he;
        int l;
        for (l = k; tt--; l++) {
          he.insert(tempp[l]);
        }
        k = l - 1;
        if (he.size() != 1) {
          flag = false;
          break;
        }
      }
      if (!flag) {
        break;
      }
      int temp = it;
      for (int j = i; temp--; j++) {
        if (s[i] != s[j]) {
          flag = false;
          break;
        }
      }
      if (flag) {
        ans = it;
      }
    }
  }
  cout << ans;
  return 0;
}
