#include <bits/stdc++.h>
using namespace std;
string arr[100000];
map<string, int> mp;
string solve(string s1, string s2, int b, int e) {
  string s = "";
  for (int i = 0, j = 0; i < s2.size() && j < s1.size(); i++, j++) {
    if (s1[j] == s2[i])
      s += s1[i];
    else {
      break;
    }
  }
  return s;
}
string result(int s, int e) {
  if (s == e) {
    return arr[s];
  }
  int mid = (s + e) / 2;
  string s1 = result(s, mid);
  string s2 = result(mid + 1, e);
  return solve(s1, s2, 0, min(s1.size() - 1, s2.size() - 1));
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  cout << result(0, n - 1).size();
}
