#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string first;
  cin >> n;
  cin >> first;
  int ans = first.size();
  for (int a = 1; a < n; a++) {
    string s;
    cin >> s;
    for (int i = 0; i <= first.size(); i++) {
      if (s[i] != first[i]) {
        ans = min(ans, i);
        break;
      }
    }
  }
  cout << ans << endl;
}
