#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
inline bool Min(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
inline bool Max(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
inline int ni() {
  int a;
  scanf("%d", &a);
  return a;
}
inline ll nl() {
  ll a;
  scanf("%lld", &a);
  return a;
}
inline double nd() {
  double a;
  scanf("%lf", &a);
  return a;
}
inline void pi(int a) { printf("%d ", a); }
inline void pl(ll a) { printf("%lld ", a); }
inline void pd(double a) { printf("%.12lf ", a); }
int diffs(string &a, string &b) {
  int res = 0;
  for (int i = 0; i < (int)(6); ++i) res += (a[i] != b[i]);
  return res;
}
void solve() {
  int n;
  cin >> n;
  vector<string> xs(n);
  for (int i = 0; i < (int)(n); ++i) cin >> xs[i];
  if (n == 1) {
    cout << 6;
    return;
  }
  int mini = 6;
  for (int i = 0; i < (int)(n); ++i)
    for (int j = (int)(i + 1); j <= (int)(n - 1); ++j)
      Min(mini, diffs(xs[i], xs[j]));
  if (mini <= 2)
    mini = 0;
  else if (mini <= 4)
    mini = 1;
  else
    mini = 2;
  cout << mini;
  ;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  srand((int)clock());
  solve();
  return 0;
}
