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