#include <bits/stdc++.h>
using namespace std;
string a, b, c;
long long n, k;
int main() {
  cin >> n >> b;
  for (int s = 1; s < n; s++) {
    cin >> a;
    c = "";
    k = min(a.size(), b.size());
    for (int v = 0; v < k; v++) {
      if (b[v] == a[v])
        c = c + b[v];
      else
        break;
    }
    b = c;
  }
  cout << b.size() << endl;
  return 0;
}
