#include <bits/stdc++.h>
using namespace std;
string s[100001], ans;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> s[i];
  ans = s[0];
  for (int j = 1; j < n; ++j) {
    int i = 0;
    string na = "";
    while (i < s[j].length() && i < ans.length() && s[j][i] == ans[i]) {
      na += ans[i++];
    }
    ans = na;
  }
  cout << ans.length() << endl;
  return 0;
}
