#include <bits/stdc++.h>
using namespace std;
int i, j, n, used[6000005] = {0}, flag = 0, a1, b1, c1, ans = 0, l = 0,
             ans2 = 0, o = 0;
char c[30000][105];
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> c[i];
    a1 = strlen(c[i]);
  }
  for (j = 0; j < a1; j++) {
    for (i = 0; i < n - 1; i++) {
      if (c[i][j] == c[i + 1][j]) {
        continue;
      } else {
        cout << ans << endl;
        return 0;
      }
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}
