#include <bits/stdc++.h>
using namespace std;
string arr[100001];
long long n;
bool func(string a, string b) {
  long long len = a.length();
  for (long long i = 0; i < len; i++) {
    if (a[i] != b[i]) {
      return false;
    }
  }
  return true;
}
bool func(long long len) {
  string s = arr[1].substr(0LL, len);
  for (long long i = 2; i <= n; i++) {
    if (!func(s, arr[i])) {
      return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  long long left = 0, right = arr[1].length();
  long long ans = 0;
  while (left <= right) {
    long long mid = (left + right) >> 1;
    if (func(mid)) {
      ans = mid;
      left = mid + 1;
    } else {
      right = mid - 1;
    }
  }
  cout << ans << endl;
}
