#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  vector<string> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int c = 0, d = 0;
  for (long long int i = 0; i < v[0].size(); i++) {
    for (long long int j = 0; j < n; j++) {
      if (v[j][i] == v[0][i]) {
        c++;
      } else {
        break;
      }
    }
    if (c != n) {
      cout << d << endl;
      return 0;
    } else {
      c = 0;
      d++;
    }
  }
  return 0;
}
