#include <bits/stdc++.h>
using namespace std;
int pref(char* mas1, char* mas2) {
  int i = 0;
  while (mas1[i] == mas2[i++])
    ;
  return --i;
}
int main() {
  int n;
  cin >> n;
  char mas[22];
  cin >> mas;
  int res = 20;
  for (int i = 1; i < n; ++i) {
    char mas1[22];
    cin >> mas1;
    res = min(res, pref(mas, mas1));
  }
  cout << res << endl;
}
