#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-6;
int main() {
  vector<string> v;
  int n, mn = 6;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  if (n == 1) {
    cout << 6 << endl;
    return 0;
  }
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int difference = 0;
      for (int k = 0; k < 6; ++k) {
        if (v[i][k] != v[j][k]) {
          difference++;
        }
      }
      mn = min(mn, difference);
    }
  }
  cout << (mn - 1) / 2 << endl;
  return 0;
}
