#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  string s;
  vector<string> v;
  while (n--) {
    cin >> s;
    v.push_back(s);
  }
  if (n == 1) {
    cout << 6;
    return 0;
  }
  int ans = 6;
  for (int i = 0; i < v.size(); i++) {
    for (int j = i + 1; j < v.size(); j++) {
      int dif = 0;
      for (int k = 0; k < 6; k++) {
        if (v[i][k] != v[j][k]) dif++;
      }
      if (dif >= 1 && dif <= 2)
        ans = 0;
      else if (dif >= 3 && dif <= 4)
        ans = min(ans, 1);
      else
        ans = min(ans, 2);
    }
  }
  cout << ans;
  return 0;
}
