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