#include <bits/stdc++.h>
using namespace std;
unordered_set<string> was;
int n, i, j, pos, k = 13, t;
string codes[1001];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (; i < n; ++i) cin >> codes[i];
  for (i = 0; i < n; ++i)
    for (j = i + 1; j < n; ++j) {
      t = 0;
      for (pos = 0; pos < 6; ++pos) t += codes[i][pos] != codes[j][pos];
      k = min(k, t);
    }
  cout << (k - 1) / 2;
  return 0;
}
