#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, cnt = 0, mx = 0, temp = 0, k = 0;
  string s[30005];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s[i];
  }
  int len = s[0].length();
  for (i = 0; i < len; i++) {
    k = 0;
    for (j = 1; j < n; j++) {
      if (s[j][i] == s[j - 1][i]) {
        temp++;
      } else {
        k = 1;
        break;
      }
    }
    if (k == 1) {
      if (cnt > mx) {
        mx = cnt;
      }
      break;
      cnt = 0;
    } else if (temp == n - 1) {
      cnt++;
      temp = 0;
    }
    if (cnt > mx) {
      mx = cnt;
    }
  }
  cout << mx << endl;
  return 0;
}
