#include <bits/stdc++.h>
using namespace std;
int main() {
  string s[30000], b;
  int n, t = 0, q = 0, a;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> s[i];
  a = s[1].length();
  for (int i = 0; i < a; i++) {
    t = 1;
    for (int j = 2; j <= n; j++) {
      if (s[j][i] != s[j - 1][i]) {
        t = 0;
      }
    }
    if (t == 1)
      q++;
    else
      break;
  }
  cout << q;
}
