#include <bits/stdc++.h>
using namespace std;
char buf[1000][7];
int n, cnt, min_diff = 6;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%s", buf[i]);
  if (n == 1) return puts("6"), 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < i; ++j) {
      cnt = 0;
      for (int k = 0; k < 6; ++k)
        if (buf[i][k] != buf[j][k]) ++cnt;
      min_diff = min(min_diff, cnt);
    }
  printf("%d\n", max(0, (min_diff + 1 >> 1) - 1));
}
