#include <bits/stdc++.h>
using namespace std;
char A[30009][30];
int main() {
  int i, j, k, n, m = 0;
  while (cin >> n) {
    for (i = 0; i < n; i++) {
      cin >> A[i];
    }
    k = strlen(A[1]);
    int flag = 0;
    for (i = 0; i < k; i++) {
      for (j = 0; j < n - 1; j++) {
        if (A[j][i] != A[j + 1][i]) {
          flag = 1;
          m = i;
          break;
        }
      }
      if (flag == 1) break;
      m = i + 1;
    }
    if (m < 0)
      cout << "0" << endl;
    else
      cout << m << endl;
  }
  return 0;
}
