#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3e4 + 10;
int n;
string s[MAX_N];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> s[i];
  int ans = 0;
  for (int i = 0; i < s[0].size(); ++i) {
    char c = s[0][i];
    for (int j = 0; j < n; ++j) {
      if (s[j][i] != c) goto x;
    }
    ans++;
  }
x:;
  cout << ans << endl;
  return 0;
}
