#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s[30005];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  int count = 0;
  for (int i = 0; i < s[0].size(); i++) {
    for (int j = 1; j < n; j++) {
      if (s[j][i] != s[j - 1][i]) {
        goto end;
      }
    }
    count++;
  }
end:
  cout << count << endl;
  return 0;
}
