#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n = 0;
  cin >> n;
  map<long long, string> mapc;
  string m;
  for (int i = 0; i < n; i++) {
    cin >> m;
    mapc[i] = m;
  }
  long long res = 6;
  for (auto& mm : mapc) {
    for (auto& ms : mapc) {
      if (ms != mm) {
        long long tres = 0;
        for (int i = 0; i < 6; i++)
          if (mm.second[i] != ms.second[i]) tres++;
        res = min(res, (tres - 1) / 2);
      }
    }
  }
  cout << res;
  return 0;
}
