#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
namespace input {
inline int nextInt() {
  int res = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') res = res * 10 + c - '0', c = getchar();
  return res;
}
inline long long nextLong() {
  long long res = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') res = res * 10 + c - '0', c = getchar();
  return res;
}
inline bool isSpace(const char &c) {
  return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
inline void next(char *str) {
  char c = getchar();
  while (isSpace(c)) c = getchar();
  size_t head = 0;
  while (!isSpace(c)) str[head++] = c, c = getchar();
  str[head] = 0;
}
inline char nextChar() {
  char c = getchar();
  while (isSpace(c)) c = getchar();
  return c;
}
}  // namespace input
using namespace input;
const int N = 1e3 + 5;
char buf[100];
string in[N];
int mx[N];
int ans[N];
void solve() {
  const int n = nextInt();
  for (int i = 0; i < n; i++) {
    next(buf);
    in[i] = buf;
  }
  for (int i = 0; i < n; i++) {
    int mx = 0;
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      int d = 0;
      for (int k = 0; k < 6; k++) {
        if (in[i][k] == in[j][k]) {
          d++;
        }
      }
      mx = max(mx, d);
    }
    if (mx >= 4) {
      ans[i] = 0;
    } else if (mx >= 2) {
      ans[i] = 1;
    } else {
      ans[i] = 2;
    }
  }
  int answer = ans[0];
  for (int i = 1; i < n; i++) {
    answer = min(answer, ans[i]);
  }
  if (n == 1) {
    answer = 6;
  }
  printf("%d\n", answer);
}
