#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
vector<string> a;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    a.push_back(s);
  }
  int k = 6;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int cnt = 0;
      for (int p = 0; p < 6; p++) {
        cnt += a[i][p] != a[j][p];
      }
      k = min(k, (cnt - 1) / 2);
    }
  }
  cout << k;
}
