#include <bits/stdc++.h>
int main() {
  int n;
  std::string s, t;
  std::cin >> n >> s;
  int x = s.size();
  while (n--) {
    std::cin >> t;
    for (int i = 0; i < x; i++) {
      if (s[i] != t[i]) {
        x = std::min(i, x);
      }
    }
  }
  std::cout << x;
}
