#include <bits/stdc++.h>
using namespace std;
int diff(const string &a, const string &b) {
  int result = 0;
  for (int i = 0; i < 6; ++i) {
    if (a[i] != b[i]) {
      ++result;
    }
  }
  return result;
}
int min_diff(const vector<string> &codes) {
  int minimum = 6;
  for (int i = 0; i < codes.size(); ++i) {
    for (int j = 0; j < codes.size(); ++j) {
      if (i == j) continue;
      minimum = min(minimum, diff(codes[i], codes[j]));
    }
  }
  return minimum;
}
int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << 6;
    return 0;
  }
  vector<string> codes(n);
  for (int i = 0; i < n; ++i) {
    cin >> codes[i];
  }
  int minimum = min_diff(codes);
  int real[] = {0, 0, 0, 1, 1, 2, 2};
  cout << real[minimum];
  return 0;
}
