#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> vs;
  for (int i = 0; i < n; i++) {
    string sx;
    cin >> sx;
    vs.push_back(sx);
  }
  int count = 0;
  bool t = true;
  for (int i = 0; i < vs[0].size(); i++) {
    for (int j = 1; j < vs.size(); j++) {
      if (vs[j][i] != vs[j - 1][i]) t = false;
    }
    if (t)
      count++;
    else
      break;
  }
  cout << count << endl;
  return 0;
}
