#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a > b; }
string s[1006];
map<string, bool> m;
int main() {
  int n, c = 0, ans = 10;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  if (n == 1) {
    cout << 6;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = 0; k < 6; k++) {
        if (s[i][k] != s[j][k]) {
          c++;
        }
      }
      ans = min(ans, c);
      c = 0;
    }
  }
  if (ans == 1 || ans == 2) {
    cout << 0;
  }
  if (ans == 3 || ans == 4) {
    cout << 1;
  }
  if (ans == 5 || ans == 6) {
    cout << 2;
  }
  return 0;
}
