#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, c = 0, j, x = 0, n;
  cin >> n;
  string s;
  vector<string> ar;
  for (i = 0; i < n; i++) {
    cin >> s;
    ar.push_back(s);
  }
  for (i = 0; i < ar[0].length(); i++) {
    for (j = 0; j < n - 1; j++) {
      if (ar[j][i] != ar[j + 1][i]) {
        x = 1;
        break;
      }
    }
    if (x == 0)
      c++;
    else
      break;
  }
  cout << c;
  return 0;
}
