#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const double PI = acos(-1);
const double EPS = 1e-8;
int main() {
  int n;
  cin >> n;
  int ans = -1;
  string prefix;
  for (int i = 0; i < (int)n; ++i) {
    string s;
    cin >> s;
    if (ans == -1) {
      ans = s.size();
      prefix = s;
    } else {
      int i;
      for (i = 0; i < ans; ++i) {
        if (prefix[i] != s[i]) break;
      }
      ans = i;
    }
  }
  cout << ans << endl;
}
