#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  std::vector<string> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  if (n == 1) {
    cout << 6 << endl;
    return 0;
  }
  int c = 6;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int n = 0;
      for (int k = 0; k < 6; k++) n += (v[i][k] != v[j][k]);
      c = min(n, c);
    }
  }
  cout << (c - 1) / 2;
  return 0;
}
