#include <bits/stdc++.h>
using namespace std;
char a[30002][20];
int n, ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < strlen(a[1]); i++) {
    for (int j = 2; j <= n; j++) {
      if (a[1][i] != a[j][i]) {
        cout << ans;
        return 0;
      }
    }
    ans++;
  }
  cout << ans;
  return 0;
}
