#include <bits/stdc++.h>
char str1[30005][30];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%s", &str1[i]);
  int mx = 0;
  for (int j = 0; str1[0][j] != 0; j++) {
    bool pl = true;
    for (int i = 0; i < n; i++) {
      if (str1[i][j] != str1[0][j]) pl = false;
    }
    if (!pl) break;
    mx++;
  }
  printf("%d\n", mx);
  return 0;
}
