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