#include <bits/stdc++.h>
using namespace std;
long n;
string a[500000];
int main() {
  cin >> n;
  long kq = 6;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      long t = 0;
      for (int l = 0; l < 6; l++)
        if (a[i][l] != a[j][l]) t++;
      kq = min(kq, (t - 1) / 2);
    }
  cout << kq;
}
