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