#include <bits/stdc++.h>
using namespace std;
int dist(string &a, string &b) {
  int res = 0;
  for (int i = 0; i < 6; i++) res += a[i] != b[i];
  return res;
}
int main() {
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 6;
  if (n == 1) {
    cout << 6;
    return 0;
  }
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      int cur = dist(a[i], a[j]);
      if (cur < ans) ans = cur;
    }
  cout << (ans - 1) / 2;
  return 0;
}
