#include <iostream>
#include <string>
#include <vector>
using namespace std ;
int main() {
   int n ;
   cin >> n ;
   vector<string> v(n) ;
   for (auto &vv: v)
      cin >> vv ;
   int lo = 0 ;
   int hi = 1 ;
   while (hi < (int)v[0].size())
      hi += hi ;
   for (; hi>0; hi >>= 1) {
      int len = lo + hi ;
      int good = 0 ;
      for (int i=0; !good && i+len<=(int)v[0].size(); i++) {
         int missing = 0 ;
         auto needle = v[0].substr(i, len) ;
         for (int j=1; !missing && j<(int)v.size(); j++)
            if (v[j].find(needle) == string::npos)
               missing = 1 ;
         if (missing == 0)
            good = 1 ;
      }
      if (good)
         lo += hi ;
   }
   cout << lo << endl ;
}
