#include <bits/stdc++.h>
using namespace std;
int n, ans;
char a[5202];
string t[520500];
int dfs(int x) {
  for (int i = 1; i <= n; i += x)
    for (int j = 1; j <= n; j += x) {
      char ch = t[i][j];
      for (int k = i; k < i + x; k++)
        for (int p = j; p < j + x; p++)
          if (t[k][p] != ch) return 0;
    }
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", a + 1);
    int len = strlen(a + 1);
    for (int j = 1; j <= len; j++) {
      if (a[j] == '0') t[i] += "0000";
      if (a[j] == '1') t[i] += "0001";
      if (a[j] == '2') t[i] += "0010";
      if (a[j] == '3') t[i] += "0011";
      if (a[j] == '4') t[i] += "0100";
      if (a[j] == '5') t[i] += "0101";
      if (a[j] == '6') t[i] += "0110";
      if (a[j] == '7') t[i] += "0111";
      if (a[j] == '8') t[i] += "1000";
      if (a[j] == '9') t[i] += "1001";
      if (a[j] == 'A') t[i] += "1010";
      if (a[j] == 'B') t[i] += "1011";
      if (a[j] == 'C') t[i] += "1100";
      if (a[j] == 'D') t[i] += "1101";
      if (a[j] == 'E') t[i] += "1110";
      if (a[j] == 'F') t[i] += "1111";
    }
  }
  for (int i = n; i >= 1; i--) {
    if (n % i == 0)
      if (dfs(i)) {
        ans = i;
        break;
      }
  }
  printf("%d", ans);
}
