#include <bits/stdc++.h>
using namespace std;
long long n, mi = 6;
string s[1111];
int main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> s[i];
  for (long long i = 1; i <= n; i++)
    for (long long j = i + 1; j <= n; j++) {
      long long cnt = 0;
      for (long long k = 0; k < 6; k++) cnt += s[i][k] != s[j][k];
      mi = min(mi, (cnt - 1) / 2);
    }
  cout << mi;
}
