#include <bits/stdc++.h>
using namespace std;
int checkDistance(string s1, string s2) {
  int distance = 0;
  for (int i = 0; i < s1.length(); ++i) {
    if (s1[i] != s2[i]) ++distance;
  }
  return distance;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  if (n == 1) {
    cout << "6" << '\n';
    return 0;
  }
  int min_distance = 7;
  for (int i = 0; i < v.size(); ++i)
    for (int j = i + 1; j < v.size(); ++j)
      min_distance = min(min_distance, checkDistance(v[i], v[j]));
  switch (min_distance) {
    case 1:
      cout << "0" << '\n';
      break;
    case 2:
      cout << "0" << '\n';
      break;
    case 3:
      cout << "1" << '\n';
      break;
    case 4:
      cout << "1" << '\n';
      break;
    case 5:
      cout << "2" << '\n';
      break;
    default:
      cout << "2" << '\n';
  }
  return 0;
}
