#include <bits/stdc++.h>
using namespace std;
string arr[1000];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  int k = 6;
  for (int i = 0; i < n - 1; i++)
    for (int j = i + 1; j < n; j++) {
      int diff = 0;
      for (int digit = 0; digit < 6; digit++)
        if (arr[i][digit] != arr[j][digit]) diff++;
      k = min((diff - 1) / 2, k);
    }
  cout << k;
  return 0;
}
