#include <bits/stdc++.h>
using namespace std;
string mass[1001];
int main() {
  int n;
  cin >> n;
  int diff = 0, diffmin = 7;
  for (int i = 0; i < n; i++) cin >> mass[i];
  for (int i = 0; i < n - 1; i++)
    for (int j = i + 1; j < n; j++) {
      for (int v = 0; v < 6; v++)
        if (mass[i][v] != mass[j][v]) diff++;
      if (diff < diffmin) diffmin = diff;
      diff = 0;
    }
  if (n == 1)
    cout << 6;
  else
    cout << (diffmin + 1) / 2 - 1;
  return 0;
}
