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