#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
string s[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> s[i];
  int ans = 6, cnt;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      cnt = 0;
      for (int k = 0; k < 6; k++)
        if (s[i][k] != s[j][k]) cnt++;
      ans = min(ans, (cnt + 1) / 2 - 1);
    }
  }
  cout << ans;
  return 0;
}
