#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int N;
  while (cin >> N) {
    vector<string> v(N);
    for (auto& s : v) cin >> s;
    int ret = v[0].size();
    for (; ret > 0; ret--) {
      for (int i = 0; i+ret <= v[0].size(); i++) {
        string s = v[0].substr(i, ret);
        bool valid = true;
        for (int j = 1; valid && j < N; j++) {
          if (v[j].find(s) == -1) valid = false;
        }
        if (valid) goto done;
      }
    }
done:
    cout << ret << endl;
  }
}
