#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  std::ios::sync_with_stdio(0);
  cin >> n;
  vector<string> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  int mx = 6;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      int p = 6;
      for (int k = 0; k < 6; ++k) {
        if (v[i][k] == v[j][k]) {
          --p;
        }
      }
      if (p < 3) {
        mx = 0;
      } else if (p < 5 && mx > 1) {
        mx = 1;
      } else if (mx > 2) {
        mx = 2;
      }
    }
  }
  printf("%d", mx);
  return 0;
}
