#include <bits/stdc++.h>
using namespace std;
int n, ans;
string s, t;
int main() {
  cin >> n >> s;
  ans = s.size();
  while (n--) {
    cin >> t;
    for (int i = 0; i < ans; i++)
      if (t[i] != s[i]) ans = min(i, ans);
  }
  cout << ans << endl;
}
