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