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