#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  int k = 2;
  bool zero = false;
  for (int i = 0; i < s.size() && !zero; i++)
    for (int j = i + 1; j < s.size() && !zero; j++) {
      int sim = 0;
      for (int m = 0; m < 6; m++) sim += s[i][m] == s[j][m];
      if (sim >= 2) k = 1;
      if (sim >= 4) {
        k = 0;
        zero = true;
        break;
      }
    }
  cout << ((n == 1) ? 6 : k);
}
