#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  vector<string> v(n);
  for (long long int i = 0; i < n; i++) {
    cin >> v[i];
  }
  long long int c = 0;
  long long int l = v[0].length();
  for (long long int i = 0; i < l; i++) {
    char x = v[0][i];
    for (long long int j = 1; j < n; j++) {
      if (v[j][i] != x) {
        cout << c << endl;
        return 0;
      }
    }
    c++;
  }
}
