#include <bits/stdc++.h>
using namespace std;
int n, ans = 6;
string a[2000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      if (i == j) continue;
      int x = 0, otv;
      for (int z = 0; z < 6; ++z)
        if (a[i][z] != a[j][z]) x++;
      if (x == 1) otv = 0;
      if (x == 2) otv = 0;
      if (x == 3) otv = 1;
      if (x == 4) otv = 1;
      if (x == 5) otv = 2;
      if (x == 6) otv = 2;
      ans = min(ans, otv);
      if (ans == 0) break;
    }
  cout << ans;
}
