#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::max;
using std::min;
using std::pair;
using std::set;
using std::string;
using std::swap;
using std::vector;
int main() {
  int n, ans, l;
  cin >> n;
  string s1, s2;
  cin >> s1;
  l = s1.length();
  ans = l;
  for (int i = 1; i < n; i++) {
    cin >> s2;
    for (int j = 0; j < ans; j++) {
      if (s1[j] != s2[j]) {
        ans = j;
      }
    }
  }
  cout << ans;
  return 0;
}
