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