#include <bits/stdc++.h>
using namespace std;
int n;
char str[1003][7];
int getDiff(char *a, char *b) {
  int sum = 0;
  for (int i = 0; i < 6; i++)
    if (a[i] != b[i]) sum++;
  return sum;
}
void get() {
  int tmp = 1000;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      tmp = min(tmp, getDiff(str[i], str[j]));
    }
  }
  cout << (n == 1 ? 6 : (tmp - 1) / 2) << endl;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> str[i];
  get();
  return 0;
}
