#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> mas(n + 1);
  for (int i = 0; i <= n; i++) {
    getline(cin, mas[i]);
  }
  int pos1, pos2;
  int raz = 6, count = 0;
  for (int i = 1; i <= n - 1; i++) {
    for (int j = i + 1; j <= n; j++) {
      for (int k = 0; k < 6; k++) {
        if (mas[i][k] != mas[j][k]) count++;
      }
      if (count < raz) {
        raz = count;
      }
      count = 0;
    }
  }
  if (n == 1) {
    cout << 6;
    return 0;
  }
  if (raz == 1) {
    cout << 0;
    return 0;
  }
  if ((raz % 2) == 0)
    cout << raz / 2 - 1;
  else
    cout << ceil(double(raz / 2));
  return 0;
}
