#include <bits/stdc++.h>
using namespace std;
const int N = 30000 + 3;
int n, k, i;
string s[N];
int main() {
  cin >> n;
  for (i = 1; i <= n; ++i) cin >> s[i];
  for (k = 1; k <= s[1].length(); ++k) {
    for (i = 1; i <= n; ++i)
      if (s[i][k - 1] != s[1][k - 1]) break;
    if (i <= n) break;
  }
  cout << k - 1;
  return 0;
}
