#include <bits/stdc++.h>
using namespace std;
void cin_array_usual(int o[], int size) {
  for (int i = 0; i < size; i++) {
    cin >> o[i];
  }
}
void print_array_usual(int o[], int size) {
  for (int i = 0; i < size; i++) {
    cout << o[i] << " ";
  }
  cout << endl;
}
void print_forward_list(forward_list<int> o) {
  for (auto i = o.begin(); i != o.end(); i++) {
    cout << *i << " ";
  }
  cout << endl;
}
void print_set(set<int> o) {
  for (auto i = o.begin(); i != o.end(); i++) {
    cout << *i << " ";
  }
  cout << endl;
}
void print_vector(vector<int> o) {
  for (int i = 0; i < o.size(); i++) {
    cout << o[i] << " ";
  }
  cout << endl;
}
int main() {
  int n;
  cin >> n;
  string o[n];
  for (int i = 0; i < n; i++) {
    cin >> o[i];
  }
  int counter = 0;
  for (int i = 0; i < o[0].size(); i++) {
    bool check = true;
    int equal;
    for (int j = 0; j < n; j++) {
      if (o[j][i] == o[0][i])
        ;
      else {
        check = false;
        break;
      }
    }
    if (check == false) {
      break;
    } else {
      counter++;
    }
  }
  cout << counter << endl;
  return 0;
}
