#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, counter = 0;
  cin >> n;
  string v[n];
  for (auto& x : v) cin >> x;
  vector<long long> ans;
  for (long long i = 0; i < n - 1; i++) {
    for (long long j = 0; j < v[0].size(); j++) {
      if (v[0][j] == v[i + 1][j]) {
        counter++;
      } else {
        ans.push_back(counter);
        counter = 0;
        break;
      }
    }
  }
  long long answer = 999999;
  for (long long i = 0; i < ans.size(); i++) {
    if (answer > ans[i]) answer = ans[i];
  }
  cout << answer << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long testcases = 1;
  while (testcases--) {
    solve();
  }
  return 0;
}
