#include <bits/stdc++.h>
using namespace std;
int main() {
  string max, min;
  string current;
  size_t k;
  cin >> k;
  cin >> current;
  max = current;
  min = current;
  for (size_t i = 0; i < k - 1; ++i) {
    cin >> current;
    if (current > max) {
      max = current;
    } else if (current < min) {
      min = current;
    }
  }
  int answer = 0;
  for (size_t i = 0; i < min.size(); ++i) {
    if (min[i] != max[i]) break;
    ++answer;
  }
  cout << answer;
}
