#include <bits/stdc++.h>
using namespace std;
const int MAX = 1001;
int n, ans = 6, dif;
bool flag = true;
string arr[MAX];
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  random_shuffle(arr, arr + n);
  for (int i = 0; i < n && flag; ++i)
    for (int j = i + 1; j < n && flag; ++j) {
      dif = 0;
      for (int k = 0; k < 6; ++k)
        if (arr[i][k] != arr[j][k]) ++dif;
      if ((dif + 1) / 2 - 1 < ans) ans = (dif + 1) / 2 - 1;
      if (ans == 0) flag = false;
    }
  cout << ans;
  return 0;
}
