#include <bits/stdc++.h>
using namespace std;
void solve(int test_number);
void pre() {
  cout.setf(ios::fixed);
  cout.precision(20);
  cerr.setf(ios::fixed);
  cerr.precision(3);
}
void post() {
  fprintf(stderr, "\n");
  fprintf(stderr, "Execution time: %Lf", (long double)clock());
}
const int MAXN = 100100;
string a[2222];
inline int dif(string &s, string &s1) {
  int ans = 0;
  for (int i = 0; i < s.size(); i++)
    if (s[i] != s1[i]) ans++;
  return ans;
}
inline void solve(int test_number) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = (int)(1e+9);
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) ans = min(ans, dif(a[i], a[j]));
  if (ans != (int)(1e+9))
    if (ans % 2 == 0)
      ans /= 2, ans = max(0, ans - 1);
    else
      ans /= 2;
  if (ans == (int)(1e+9)) ans = 6;
  printf("%d", ans);
  return;
}
int main() {
  pre();
  int n = 1;
  for (int i = 0; i < n; i++) {
    solve(i + 1);
  }
  post();
  return 0;
}
