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