#include <bits/stdc++.h>
using namespace std;
int main() {
  string S1, S2;
  int n = 0, i, nr, j, min1 = 0;
  cin >> n;
  cin >> S1;
  nr = S1.size();
  min1 = nr;
  for (i = 2; i <= n; i++) {
    cin >> S2;
    j = 0;
    while (S1[j] == S2[j] && j < nr) ++j;
    if (min1 > j) min1 = j;
  }
  cout << min1;
  return 0;
}
