#include <bits/stdc++.h>
#pragma warning(error : 4700)
#pragma warning(error : 4715)
#pragma warning(error : 4716)
using namespace std;
const long long MILLER_RABIN = 3215031751;
const long double PI = 3.14159265358979323846;
inline int lg2(long long n) {
  int h = 0;
  while ((1ll << h) < n) ++h;
  return h;
}
struct config_io {
  config_io() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
  }
} cnf_io;
struct config_rand {
  config_rand() {
    srand(chrono::duration_cast<chrono::nanoseconds>(
              chrono::high_resolution_clock::now().time_since_epoch())
              .count());
  }
} cnf_rand;
namespace std {
template <>
struct hash<pair<int, int> > {
  size_t operator()(const pair<int, int>& x) const {
    return (x.first * 31 + x.second) % ((int)1e9 + 7);
  }
};
}  // namespace std
int main() {
  int n;
  cin >> n;
  vector<string> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  if (n == 1) {
    cout << 6 << endl;
  } else {
    int mind = 10;
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        int curd = 0;
        for (int k = 0; k < 6; ++k) {
          if (v[i][k] != v[j][k]) ++curd;
        }
        mind = min(mind, curd);
      }
    }
    cout << (mind - 1) / 2 << endl;
  }
  return 0;
}
