#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int main() {
  int n;
  scanf("%d\n", &n);
  if (n == 1) {
    printf("6\n");
    return 0;
  }
  vector<string> v;
  set<string> S;
  for (int i = 0; i < n; i++) {
    string s;
    getline(cin, s);
    S.insert(s);
    v.push_back(s);
    for (int j = 0; j < 6; j++) {
      for (int k = 0; k < 10; k++) {
        string t = s;
        t[j] = k + '0';
        if (s[j] == k + '0') continue;
        S.insert(t);
      }
    }
  }
  if (static_cast<int>((S).size()) < 55 * n) {
    printf("0");
    return 0;
  }
  assert(55 * n == static_cast<int>((S).size()));
  for (int i = 0; i < n; i++) {
    for (int p1 = 0; p1 < 6; p1++) {
      for (int p2 = p1 + 1; p2 < 6; p2++) {
        for (int c1 = 0; c1 < 10; c1++) {
          for (int c2 = 0; c2 < 10; c2++) {
            if (c1 + '0' != v[i][p1] && c2 + '0' != v[i][p2]) {
              string t = v[i];
              t[p1] = '0' + c1;
              t[p2] = '0' + c2;
              S.insert(t);
            }
          }
        }
      }
    }
  }
  if (static_cast<int>((S).size()) < n * (15 * 9 * 9 + (6 * 9 + 1))) {
    printf("1");
    return 0;
  }
  assert(static_cast<int>((S).size()) == n * (15 * 9 * 9 + (6 * 9 + 1)));
  printf("2");
  return 0;
}
