#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char a[n][6];
  int i;
  for (i = 0; i < n; i++) {
    int j;
    for (j = 0; j < 6; j++) {
      cin >> a[i][j];
    }
  }
  int min = 7;
  for (i = 0; i < n - 1; i++) {
    int j;
    for (j = i + 1; j < n; j++) {
      int count = 0;
      int z;
      for (z = 0; z < 6; z++) {
        if (a[i][z] != a[j][z]) {
          count++;
        }
      }
      if (count < min) {
        min = count;
      }
    }
  }
  int ans;
  if (min == 7) {
    ans = 6;
  } else if (min % 2 == 0) {
    ans = (min / 2) - 1;
  } else {
    ans = min / 2;
  }
  cout << ans;
  return 0;
}
