#include <bits/stdc++.h>
using namespace std;
int const N = 1111;
int const INF = 6;
string s[N];
int n;
int ans = INF;
map<pair<int, int>, int> mp;
int main() {
  cin >> n;
  for (int c = 1; c <= n; c++) {
    cin >> s[c];
  }
  mp[{0, 6}] = 2;
  mp[{1, 5}] = 2;
  mp[{2, 4}] = 1;
  mp[{3, 3}] = 1;
  mp[{4, 2}] = 0;
  mp[{5, 1}] = 0;
  mp[{6, 0}] = 0;
  for (int c = 1; c <= n; c++) {
    for (int i = c + 1; i <= n; i++) {
      int z = 0, x = 0;
      for (int j = 0; j < 6; j++) {
        if (s[c][j] == s[i][j])
          z++;
        else
          x++;
      }
      ans = min(ans, mp[{z, x}]);
    }
  }
  cout << ans;
  return 0;
}
