#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T sqr(const T& x) {
  return x * x;
}
template <class T>
inline void updMin(T& a, const T& b) {
  if (b < a) a = b;
}
template <class T>
inline void updMax(T& a, const T& b) {
  if (b > a) a = b;
}
vector<string> a;
int cross(int i, int j) {
  int neq = 0;
  for (int t = 0; t < 6; t++) {
    if (a[i][t] != a[j][t]) neq++;
  }
  return (neq + 1) / 2;
}
int main() {
  int n;
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << 6 << "\n";
  } else {
    int ans = 6;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        ans = min(ans, cross(i, j) - 1);
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
