#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  string* str = new string[n];
  int prefix = 0;
  for (int i = 0; i < n; ++i) cin >> str[i];
  for (int i = 0; i < str[0].length(); ++i) {
    for (int j = 0; j < n - 1; ++j) {
      if (str[j][i] != str[j + 1][i]) {
        printf("%d\n", prefix);
        return 0;
      }
    }
    ++prefix;
  }
  printf("%d\n", prefix);
  return 0;
}
