#include <bits/stdc++.h>
using namespace std;
char a[30001][21];
int main() {
  int n, sum = 0, cd;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  cd = strlen(a[1]);
  for (int i = 0; i <= cd - 1; i++) {
    for (int l = 2; l <= n; l++) {
      if (a[l][i] != a[l - 1][i]) {
        cout << sum;
        return 0;
      }
    }
    sum++;
  }
  cout << sum;
  return 0;
}
