#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, ans = 6;
  cin >> k;
  vector<string> v(k);
  for (int i = 0; i < k; ++i) {
    cin >> v[i];
  }
  for (int i = 0; i < k; ++i) {
    for (int j = i + 1; j < k; ++j) {
      int tmp = 0;
      for (int m = 0; m < 6; ++m) {
        if (v[i][m] != v[j][m]) tmp++;
      }
      ans = min(ans, (tmp - 1) / 2);
    }
  }
  cout << ans;
  getchar();
  getchar();
  return 0;
}
