#include <bits/stdc++.h>
using namespace std;
long long n;
string a[1111];
long long deg[11];
long long ans;
signed main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  if (n == 1) {
    cout << 6;
    return 0;
  }
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  ans = 0;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= n; ++j) {
      if (i == j) continue;
      long long cnt = 0;
      for (long long k = 0; k < 6; ++k) {
        long long x = a[i][k];
        long long y = a[j][k];
        if (x == y) ++cnt;
      }
      if (cnt >= 4) {
        cout << ans;
        return 0;
      }
    }
  }
  ans = 1;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= n; ++j) {
      if (i == j) continue;
      long long cnt = 0;
      for (long long k = 0; k < 6; ++k) {
        long long x = a[i][k];
        long long y = a[j][k];
        if (x == y) ++cnt;
      }
      if (cnt >= 2) {
        cout << ans;
        return 0;
      }
    }
  }
  cout << 2;
  return 0;
}
