#include <bits/stdc++.h>
using namespace std;
int n, k;
int main() {
  string f, s;
  cin >> n >> f;
  int p = f.size();
  int ne = p;
  while (--n) {
    cin >> s;
    for (int i = p - 1; i >= 0; i--) {
      if (f[i] != s[i]) ne = i;
      p = ne;
    }
  }
  cout << p;
}
