#include <bits/stdc++.h>
using namespace std;
char g[30001][21];
int main() {
  int n;
  cin >> n;
  cin >> g[0];
  int l = 0;
  for (int i = 1; i < n; ++i) {
    cin >> g[i];
  }
  int f = 0;
  for (int i = 0; i < strlen(g[0]); ++i) {
    for (int j = 0; j < n - 1; ++j) {
      if (g[j][i] == g[j + 1][i]) {
        ++f;
      } else {
        cout << l;
        return 0;
      }
    }
    if (f == n - 1) {
      l++;
    }
    f = 0;
  }
  cout << l;
  return 0;
}
