#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << "6" << endl;
    return 0;
  }
  vector<string> A(n);
  for (int i = 0; i < n; ++i) cin >> A[i];
  int dist = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      int di = 0;
      for (int t = 0; t < 6; ++t)
        if (A[i][t] == A[j][t]) di++;
      dist = max(dist, di);
    }
  }
  if (dist >= 4) {
    cout << "0" << endl;
    return 0;
  }
  if (dist >= 2) {
    cout << "1" << endl;
    return 0;
  }
  cout << "2" << endl;
  return 0;
}
