#include <bits/stdc++.h>
using namespace std;
const long long int INF = 987698769876988899LL;
const int MOD = 1e9 + 7;
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dx4[] = {1, -1, 0, 0};
const int dy4[] = {0, 0, 1, -1};
const int N = 1e3 + 3;
string s[N];
int ans = 6, n;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      int cur = 0;
      for (int k = 0; k < s[i].length(); k++) {
        if (s[i][k] != s[j][k]) cur++;
      }
      ans = min(ans, (cur - 1) / 2);
    }
  }
  cout << ans;
}
