#include <bits/stdc++.h>
using namespace std;
const int NMAX = 123456;
const int XMAX = 1234567;
int n;
string codes[1111];
int diff(string s1, string s2) {
  int cnt = 0;
  for (int i = 0; i < 6; i++) cnt += s1[i] != s2[i];
  return cnt;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> codes[i];
  if (n == 1) {
    cout << 6;
    return 0;
  }
  int minDiff = 10;
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++)
      minDiff = min(minDiff, diff(codes[i], codes[j]));
  if (minDiff <= 2)
    cout << 0;
  else if (minDiff <= 4)
    cout << 1;
  else
    cout << 2;
  return 0;
}
