#include <bits/stdc++.h>
using namespace std;
char z[10000];
void cmp(char a[], char b[], int i, int n, int j) {
  if (i == n || a[0] != b[0]) return;
  if (a[i] == b[i]) z[j++] = a[i];
  cmp(a, b, i + 1, n, j);
}
void cmp2(string a, int p, int n) {
  if (p == n) return;
  if (z[p] != a[p]) {
    for (; p < n; p++) z[p] = '\0';
    return;
  }
  cmp2(a, p + 1, n);
}
int main() {
  int x, k = 0, n;
  char a[100000], b[100000];
  scanf("%d", &x);
  while (x) {
    if (!k) {
      scanf("%s%s", a, b);
      n = min(strlen(a), strlen(b));
      cmp(a, b, 0, n, 0);
      x -= 2;
    } else {
      scanf("%s", a);
      n = strlen(z);
      cmp2(a, 0, n);
      x--;
    }
    k++;
  }
  printf("%d", strlen(z));
}
