#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:33554432")
using namespace std;
long long MOD = 1e9 + 7;
const int MAXN = 2 * 100001;
long long data_inp[MAXN];
int n, k;
int A[5200][2000];
int B[5200][2000];
bool poss(int val) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n / 4; j++) {
      B[i][j] = -1;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n / 4; j++) {
      if (B[i / val][j / val] == -1) {
        B[i / val][j / val] = A[i][j];
      } else if (B[i / val][j / val] != A[i][j])
        return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    char curr;
    for (int j = 0; j < n / 4; j++) {
      scanf("%c", &curr);
      A[i][j] = curr > '9' ? curr - 'A' + 10 : curr - '0';
    }
    scanf("%c", &curr);
  }
  int answer = 1;
  for (int i = 4; i <= n; i += 4) {
    if (n % i == 0 && poss(i)) answer = i;
  }
  cout << answer;
  return 0;
}
