#include <bits/stdc++.h>
using namespace std;
int dif(string s, string h) {
  int ans = 0;
  for (long long(i) = 0; (i) < (s.size()); ++(i)) {
    if (s[i] != h[i]) {
      ++ans;
    }
  }
  return ans;
}
void solve() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (long long(i) = 0; (i) < (n); ++(i)) {
    cin >> s[i];
  }
  int minn = 6;
  for (long long(i) = 0; (i) < (n); ++(i)) {
    for (long long(j) = 0; (j) < (n); ++(j)) {
      if (i == j) {
        continue;
      }
      minn = min(minn, dif(s[i], s[j]));
    }
  }
  if (n == 1)
    cout << 6;
  else
    cout << (minn + 1) / 2 - 1;
}
int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
