#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> code(n);
  for (int i = 0; i < n; i++) {
    cin >> code[i];
  }
  int minS = 7;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      string c1 = code[i];
      string c2 = code[j];
      int s = 0;
      for (int k = 0; k < 6; k++) {
        if (c1.substr(k, 1) != c2.substr(k, 1)) s++;
      }
      minS = min(s, minS);
    }
  if (n == 1)
    cout << 6 << endl;
  else
    cout << (minS - 1) / 2 << endl;
  return 0;
}
