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