#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
inline int ReadIn() {
  char ch = getchar();
  int data = 0;
  while (ch < '0' || ch > '9') ch = getchar();
  do {
    data = data * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return data;
}
char str[1001][7];
int main() {
  int n;
  n = ReadIn();
  int max = 6;
  for (int i = 0; i < n; i++) scanf("%s", str[i]);
  if (n == 1) {
    puts("6");
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (max == 1) break;
    for (int j = i + 1; j < n; j++) {
      int tep = 0;
      for (int k = 0; k < 6; k++)
        if (str[i][k] != str[j][k]) tep++;
      if (tep < max) max = tep;
    }
  }
  printf("%d\n", (max - 1) / 2);
  return 0;
}
