#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T a) {
  return (a) * (a);
}
template <class T>
T abs(T a) {
  return (a < 0) ? -(a) : (a);
}
const double Pi = acos(-1.0);
const double eps = 1e-10;
const int INF = 1000 * 1000 * 1000;
const double phi = 0.5 + sqrt(1.25);
int main() {
  string Less = "z", More = " ", tmp = "";
  int n;
  scanf("%d\n", &n);
  for (int i = 0, _n = (n)-1; i <= _n; ++i) {
    getline(cin, tmp);
    Less = min(Less, tmp);
    More = max(More, tmp);
  }
  int i = 0, m = ((int)((Less).size()));
  bool coincide = 1;
  while (i < m && coincide)
    if (Less.substr(0, i + 1) == More.substr(0, i + 1))
      i++;
    else
      coincide = 0;
  printf("%d\n", i);
  return 0;
}
