#include <bits/stdc++.h>
using namespace std;
int N = 20;
char T[21];
void strcomp(char* a, char* b) {
  int i;
  for (i = 0; i < N, a[i] == b[i]; i++) T[i] = a[i];
  T[i] = '\0';
}
int main() {
  int n;
  cin >> n;
  char acc[21], a[21], b[21];
  cin >> a;
  for (int i = 2; i <= n; i++) {
    cin >> b;
    N = strlen(a);
    strcomp(a, b);
    strcpy(a, T);
  }
  cout << strlen(a) << endl;
  return 0;
}
