#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<string> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
  }
  int len = v[0].length();
  for (int j = len; j >= 1; j--) {
    bool check = true;
    string klma = v[0].substr(0, j);
    for (int i = 0; i < n; i++) {
      if (v[i].find(klma) != 0) {
        check = false;
        break;
      }
    }
    if (check == true) {
      cout << klma.length() << endl;
      return 0;
    }
  }
  cout << "0" << endl;
  return 0;
}
