#include <bits/stdc++.h>
using namespace std;
string s[30000];
int main() {
  int t;
  scanf("%d", &t);
  for (int i = 0; i < t; i++) cin >> s[i];
  string m = "";
  for (int i = 0; i < s[0].length(); i++) {
    char c = s[0][i];
    char b;
    for (int j = 0; j < t; j++) {
      b = s[j][i];
      if (b != c) break;
    }
    if (b != c) break;
    m += c;
  }
  cout << m.length() << endl;
  return 0;
}
