#include <bits/stdc++.h>
using namespace std;
bool ceksubstr(string c[], int sub, int n) {
  bool valid = true;
  int i = 0;
  while (i < n && valid) {
    if (c[i].substr(sub, 1) != c[0].substr(sub, 1)) {
      valid = false;
    }
    i++;
  }
  return valid;
}
int main() {
  int n, digit = 0, iter = 0;
  cin >> n;
  string contact[n];
  for (int i = 0; i < n; i++) {
    cin >> contact[i];
  }
  bool cont = true;
  while (iter < contact[0].length() && cont) {
    if (ceksubstr(contact, iter, n)) {
      digit++;
    } else {
      cont = false;
    }
    iter++;
  }
  cout << digit << endl;
  return 0;
}
