#include <bits/stdc++.h>
using namespace std;
const int maxn = 200100;
string s[1005];
int main() {
  int n;
  scanf("%d", &n);
  int ans = 6;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int tmp = 0;
      for (int k = 0; k < 6; k++)
        if (s[i][k] != s[j][k]) tmp++;
      ans = min(ans, (tmp - 1) / 2);
    }
  }
  cout << ans << endl;
}
