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