#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:36777216")
using namespace std;
const int inf = 1 << 30;
const long long Inf = 1LL << 62;
const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1, 0};
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
const double eps = 1e-9;
const double pi = 3.1415926535897932384626433832795;
template <class T>
inline bool eq(const T &a, const T &b) {
  return fabs(a - b) < eps;
}
template <class T>
inline bool deg2(const T &n) {
  return (n & (n - 1)) == 0;
}
template <class T>
inline void chmax(T &a, const T &b) {
  a = max(a, b);
}
inline int intRand(int l, int r) {
  return ((rand() << 16) | rand()) % (r - l + 1) + l;
}
inline long long llRand(long long l, long long r) {
  return (((1ll * rand()) << 48) | ((1ll * rand()) << 32) | (rand() << 16) |
          rand()) %
             (r - l + 1) +
         l;
}
int i, n, len, j;
string s, pr;
int main() {
  ios_base::sync_with_stdio(false);
  srand(time(NULL));
  cin >> n;
  cin >> pr;
  len = (int)pr.size();
  for (i = 1; i < n; i++) {
    cin >> s;
    for (j = 0; j < len; j++)
      if (s[j] != pr[j]) break;
    len = j;
    pr = s;
  }
  cout << len;
  return 0;
}
