#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, ans = 0;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < a[0].size(); ++i) {
    if (a[0][i] == a[n - 1][i]) {
      ++ans;
    } else
      break;
  }
  cout << ans;
  return 0;
}
