#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> str(n);
  for (int i = 0; i < n; ++i) cin >> str[i];
  sort(str.begin(), str.end());
  string a = str.front();
  string b = str.back();
  int i = 0;
  while (i < a.size() && a[i] == b[i]) i++;
  cout << i << endl;
}
