#include <bits/stdc++.h>
using namespace std;
string s[1013];
int sravn(string st, string str) {
  int cnt = 0;
  for (int i = 0; i < 6; i++) {
    if (st[i] == str[i]) cnt++;
  }
  return cnt;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  int k = 6;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int sr = sravn(s[i], s[j]);
      if (sr == 5 || sr == 4) k = min(0, k);
      if (sr == 3 || sr == 2) k = min(1, k);
      if (sr == 0 || sr == 1) k = min(2, k);
    }
  }
  cout << k;
  return 0;
}
