#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:30000000")
using namespace std;
const double EPS = 1E-8;
const int INF = (int)1E+9;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = s.length();
  for (int i = 1; i < n; ++i) {
    string str;
    cin >> str;
    for (int j = 0; j < ans; ++j)
      if (str[j] != s[j]) ans = j;
  }
  cout << ans;
  return 0;
}
