#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> a(n, "");
  int r = 6;
  cin >> a[0];
  short s;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < i; j++) {
      s = 0;
      for (int k = 0; k < 6; k++) s += (a[i][k] != a[j][k]);
      r = min(r, (s - 1) / 2);
    }
  }
  cout << r << endl;
  return 0;
}
