#include <bits/stdc++.h>
const long long mod = (long long)1e9 + 7;
const int maxn = (int)6e5 + 2;
long long inf = 1LL << 60;
const double eps = 1e-9;
double pi = 3.14159265359;
using namespace std;
template <class N>
inline void read(N &n) {
  N x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  n = x * f;
}
string a[1001];
int main() {
  int n;
  cin >> n;
  if (n == 1) cout << 6, exit(0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int r = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int now = 0;
      for (int k = 0; k < 6; k++) {
        if (a[i][k] == a[j][k]) now++;
      }
      r = max(now, r);
    }
  }
  if (r < 2)
    cout << 2;
  else if (r < 4)
    cout << 1;
  else
    cout << 0;
  return 0;
}
