#include <bits/stdc++.h>
using namespace std;
using pii = pair<long long, long long>;
ostream& operator<<(ostream& os, const pii& seg) {
  return os << "[" << seg.first << ", " << seg.second << "]";
}
istream& operator>>(istream& is, pii& p) {
  is >> p.first >> p.second;
  return is;
}
int main() {
  ios_base::sync_with_stdio(0);
  auto& in = cin;
  auto& out = cout;
  int n;
  in >> n;
  vector<string> promo(n);
  for (auto& p : promo) in >> p;
  int min_res = 6;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int d = 0;
      for (int k = 0; k < 6; ++k) d += promo[i][k] != promo[j][k];
      min_res = min(min_res, (d - 1) >> 1);
    }
  }
  out << min_res << "\n";
  return 0;
}
