#include <bits/stdc++.h>
using namespace std;
string a[1005];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int res = 0;
  int mn = 13;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      string b = a[i];
      string c = a[j];
      res = 0;
      for (int k = 0; k < 6; k++) {
        if (b[k] != c[k]) res++;
      }
      mn = min(mn, res);
    }
  }
  cout << (mn - 1) / 2 << endl;
  return 0;
}
