#include <bits/stdc++.h>
using namespace std;
string mapch[256];
string map[5210];
void init() {
  mapch['0'] = "0000";
  mapch['1'] = "0001";
  mapch['2'] = "0010";
  mapch['3'] = "0011";
  mapch['4'] = "0100";
  mapch['5'] = "0101";
  mapch['6'] = "0110";
  mapch['7'] = "0111";
  mapch['8'] = "1000";
  mapch['9'] = "1001";
  mapch['A'] = "1010";
  mapch['B'] = "1011";
  mapch['C'] = "1100";
  mapch['D'] = "1101";
  mapch['E'] = "1110";
  mapch['F'] = "1111";
}
int n;
int main() {
  ios::sync_with_stdio(false);
  srand(time(NULL));
  init();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < s.size(); j++) map[i] += mapch[s[j]];
  }
  char ch = map[0][0];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (map[i][j] != ch) {
        cout << "1" << endl;
        return 0;
      }
  cout << n << endl;
  return 0;
}
