#include <bits/stdc++.h>
int main() {
  int n, i, j, min = 40;
  char s0[30];
  char s[30];
  scanf("%d", &n);
  scanf("%s", s0);
  for (i = 2; i <= n; i++) {
    scanf("%s", s);
    j = 0;
    while (s0[j] == s[j]) j++;
    if (j < min) min = j;
  }
  printf("%d", min);
  return 0;
}
