#include <bits/stdc++.h>
using namespace std;
char s[30005][25];
int n;
int main() {
  while (~scanf("%d", &n)) {
    int mi = 99;
    for (int i = 0; i < n; i++) {
      scanf("%s", s[i]);
      mi = min(mi, (int)strlen(s[i]));
    }
    for (; mi > 0; mi--) {
      int can = 1;
      for (int i = 1; i < n; i++)
        if (strncmp(s[0], s[i], mi) != 0) {
          can = 0;
          break;
        }
      if (can) {
        printf("%d\n", mi);
        break;
      }
    }
    if (mi == 0) puts("0");
  }
}
