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