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