#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s, first;
  cin >> n >> first;
  n--;
  while (n--) {
    cin >> s;
    while (first != s.substr(0, first.length())) {
      first = first.substr(0, first.length() - 1);
    }
  }
  cout << first.length();
}
