#include <bits/stdc++.h>
using namespace std;
int ff(string s, string ss) {
  int ans = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == ss[i]) {
      ++ans;
    }
  }
  return ans;
}
string a[2000];
signed main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << 6 << endl;
    return 0;
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      int cur = ff(a[i], a[j]);
      ans = max(cur, ans);
    }
  }
  cout << (6 - ans + 1) / 2 - 1 << endl;
}
