#include<cstdio>
#include<cstring>

int main()
{
        char r[2][4002] = {};
        while (gets (r[0])) {
                gets (r[1]);
                int d[2][4002] = {}, le, ri, a = 0;
                le = strlen (r[0]), ri = strlen (r[1]);
                for (int i=1; i<=le; i++) {
                        for (int j=1; j<=ri; j++) {
                                if (r[0][i-1] == r[1][j-1]) d[i&1][j] = d[1-(i&1)][j-1] + 1;
                                else d[i&1][j] = 0;
                                a = a>d[i&1][j] ? a:d[i&1][j];
                        }
                }
                printf ("%d\n", a);
        }
        return 0;
}