#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> num;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    num.push_back(s);
  }
  int ans = num[0].length();
  for (int i = 0; i < n - 1; i++) {
    int temp = 0;
    for (int j = 0; j < ans; j++) {
      if (num[i][j] == num[i + 1][j]) {
        temp++;
      } else {
        ans = min(temp, ans);
        break;
      }
    }
  }
  cout << ans;
  return 0;
}
