#include <bits/stdc++.h>
using namespace std;
int n, sum = 0, ans = 0, sz;
string s;
char c[30001][50];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    sz = s.size();
    for (int j = 0; j < s.size(); j++) c[i][j] = s[j];
  }
  for (int i = 0; i < sz; i++) {
    for (int j = 0; j <= n; j++) {
      if (j != 0) {
        if (c[j][i] == c[j - 1][i]) ans++;
      }
    }
    if (ans == n - 1)
      sum++;
    else
      break;
    ans = 0;
  }
  cout << sum;
  return 0;
}
