#include <bits/stdc++.h>
using namespace std;
const double PI = std::atan(1.0) * 4;
int main(int argc, char* argv[]) {
  int n;
  cin >> n;
  string previous, actual;
  cin >> previous;
  int last = previous.size() - 1;
  for (int i = 0; i < n; ++i) {
    cin >> actual;
    for (int j = 0; j < previous.size(); ++j) {
      if (actual.at(j) != previous.at(j)) {
        last = min(j, last);
      }
    }
    previous = actual;
  }
  cout << last << endl;
  return EXIT_SUCCESS;
}
