#include <bits/stdc++.h>
using namespace std;
const int MXN = (int)1e6 + 10;
const int INF = (int)1e9 + 7;
const long long LINF = (long long)1e18 + 10;
const double EPS = (double)1e-9;
const double PI = (double)acos(-1.0);
string s[1111];
int n;
int ans = 6;
inline int dist(int id1, int id2) {
  int ret = 0;
  for (int i = 0; i < 6; ++i) {
    ret += (s[id1][i] != s[id2][i]);
  }
  return ret;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      ans = min(ans, (dist(i, j) + 1) / 2 - 1);
    }
  }
  printf("%d", ans);
  return 0;
}
