#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
int n;
int ans = 6;
vector<string> s;
int dist(string &s1, string &s2) {
  int res = 0;
  for (int i = 0; i < s1.size(); i++) {
    if (s1[i] != s2[i]) {
      res++;
    }
  }
  return res;
}
void solve() {
  cin >> n;
  s.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < i; j++) {
      ans = min(ans, (dist(s[i], s[j]) - 1) >> 1);
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  srand(1313);
  solve();
  return 0;
}
