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