#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<string> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  int max_c = 0;
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j) {
      int c = 0;
      for (int k = 0; k < 6; ++k)
        if (v[i][k] == v[j][k]) ++c;
      max_c = max(c, max_c);
    }
  if (n == 1)
    cout << 6;
  else if (6 - max_c >= 5)
    cout << 2;
  else if (6 - max_c >= 3)
    cout << 1;
  else
    cout << 0;
  return 0;
}
