#include <bits/stdc++.h>
using namespace std;
int n;
vector<string> v;
string fullform(string s) {
  string temp = ">";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      temp += "0000";
    else if (s[i] == '1')
      temp += "0001";
    else if (s[i] == '2')
      temp += "0010";
    else if (s[i] == '3')
      temp += "0011";
    else if (s[i] == '4')
      temp += "0100";
    else if (s[i] == '5')
      temp += "0101";
    else if (s[i] == '6')
      temp += "0110";
    else if (s[i] == '7')
      temp += "0111";
    else if (s[i] == '8')
      temp += "1000";
    else if (s[i] == '9')
      temp += "1001";
    else if (s[i] == 'A')
      temp += "1010";
    else if (s[i] == 'B')
      temp += "1011";
    else if (s[i] == 'C')
      temp += "1100";
    else if (s[i] == 'D')
      temp += "1101";
    else if (s[i] == 'E')
      temp += "1110";
    else if (s[i] == 'F')
      temp += "1111";
  }
  return temp;
}
void input() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  v.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    v[i] = fullform(v[i]);
  }
}
bool check(int stop) {
  for (int i = 1; i <= stop; i++) {
    for (int j = 1; j <= stop; j++) {
      if (v[i][j] != v[i * stop][j * stop]) return 0;
    }
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  input();
  int ans = 1;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 1) {
      if (check(i)) {
        ans = i;
      }
    }
  }
  cout << ans << endl;
}
