#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const long double pi = acos(-1.0);
const long long inf = 1e+9;
#pragma comment(linker, "/STACK:36777216")
template <typename T>
istream &operator>>(istream &, vector<T> &);
template <typename T>
ostream &operator<<(ostream &, const vector<T> &);
void solve() {
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 6;
  for (int i = 0; i < n; i++)
    for (int k = i + 1; k < n; k++) {
      int dif = 0;
      for (int j = 0; j < 6; j++) dif += (a[i][j] != a[k][j]);
      ans = min(ans, max(0, dif - 1) / 2);
    }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (int i = 0; i < v.size(); ++i) is >> v[i];
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < v.size(); ++i) os << v[i];
  return os;
}
