#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char numbers[35000][25];
  for (int i = 0; i < n; i++) {
    cin >> numbers[i];
  }
  int num = 0;
  for (int i = 0; i < 25; i++) {
    for (int j = 0; j < n - 1; j++) {
      if (numbers[j][i] != numbers[j + 1][i]) {
        cout << num << endl;
        return 0;
      }
    }
    num++;
  }
  cout << num << endl;
  return 0;
}
