#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    string str[40000];
    for (int i = 0; i < n; ++i) cin >> str[i];
    int cont = 0;
    int size = str[0].size();
    for (int i = 0; i < size; ++i) {
      int j;
      for (j = 1; j < n; ++j)
        if (str[j][i] != str[j - 1][i]) break;
      if (j >= n)
        cont++;
      else
        break;
    }
    cout << cont << endl;
  }
  return 0;
}
