#include <bits/stdc++.h>
using namespace std;
int Set(int mask, int pos) { return mask = mask | (1 << pos); }
bool check(int mask, int pos) { return (bool)(mask & (1 << pos)); }
int csUnique[5250];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  map<string, int> mp;
  string str;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> str;
    csUnique[i + 1] = csUnique[i];
    if (mp[str] == 0) {
      csUnique[i + 1]++;
      mp[str]++;
    }
  }
  vector<int> divisors;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      divisors.push_back(i);
      if (n / i != i) {
        divisors.push_back(n / i);
      }
    }
  }
  sort(divisors.begin(), divisors.end());
  reverse(divisors.begin(), divisors.end());
  int m = divisors.size() - 1;
  for (int i = 0; i < m; i++) {
    bool found = true;
    for (int j = divisors[i]; j <= n; j += divisors[i]) {
      if (csUnique[j] - csUnique[j - divisors[i]] != 1) {
        found = false;
        break;
      }
    }
    if (found) {
      cout << divisors[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  return 0;
}
