#include <bits/stdc++.h>
int a[5009][6], n, mn, k, b;
using namespace std;
int st(int a, int b) {
  int c = 1;
  for (int i = 1; i <= b; i++) c = c * a;
  return c;
}
void wrt(int b, int j) {
  for (int i = 1; i <= 6; i++) a[j][i] = b % st(10, i) / st(10, i - 1);
}
int main() {
  mn = 100;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> b;
    wrt(b, i);
  }
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      k = 0;
      for (int l = 1; l <= 6; l++) {
        if (a[i][l] != a[j][l]) k++;
      }
      if (k < mn) mn = k;
    }
  }
  if (n == 1)
    cout << 6;
  else
    cout << (mn - 1) / 2;
}
