// @snippet<sh19910711/contest:headers.cpp>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <limits>
#include <complex>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

// @snippet<sh19910711/contest:solution/interface.cpp>
namespace solution {
    class ISolution {
    public:
        virtual void init() {};
        virtual bool input() { return false; };
        virtual void output() {};
        virtual int run() = 0;
    };
}

// @snippet<sh19910711/contest:text/suffix_array.cpp>
namespace text {
    class SuffixArray {
    public:
        typedef std::vector<int> VI;
        std::string s;
        int n, k;
        VI sa, rank, height;
        void build() {
            int maxlen = n;
            for ( int i = 0; i < n; ++ i ) rank[i] = s[i], maxlen = std::max( maxlen, s[i] + 1 );
            VI cnt(maxlen, 0);
            for ( int i = 0; i < n; ++ i ) cnt[rank[i]] ++;
            for ( int i = 1; i < maxlen; ++ i ) cnt[i] += cnt[i-1];
            for ( int i = 0; i < n; ++ i ) sa[--cnt[rank[i]]] = i;
            for ( k = 1; k < n; k *= 2 ) {
                VI r = rank;
                rank[sa[0]] = 0;
                for ( int i = 1; i < n; ++ i ) {
                    int s1 = sa[i-1], s2 = sa[i];
                    rank[s2] = r[s1] == r[s2] && std::max( s1, s2 ) + k < n && r[s1+k/2] == r[s2+k/2] ? rank[s1] : i;
                }
                for ( int i = 0; i < n; ++ i ) cnt[i] = i;
                VI s = sa;
                for ( int i = 0; i < n; ++ i ) {
                    int s1 = s[i] - k;
                    if ( s1 >= 0 ) sa[cnt[rank[s1]]++] = s1;
                }
            }
        }
        SuffixArray() {
            init("");
        }
        SuffixArray( const std::string& s_ ) {
            init(s_);
        }
        void init( const std::string& s_ ) {
            s = s_; n = s.size(); sa.resize(n); rank.resize(n+1);height.resize(std::max(0,n-1));
        }
        VI::iterator begin() { return sa.begin(); }
        VI::iterator end() { return sa.end(); }
        int& operator []( int k ) { return sa[k]; }
        int size() { return n; }

        bool find( const std::string& key ) {
            int lb = 0, ub = n;
            while ( ub - lb > 1 ) {
                int mid = ( lb + ub ) / 2;
                std::string t = s.substr( sa[mid] );
                if ( t.substr( 0, key.size() ) == key ) {
                    return true;
                } else if ( t < key ) {
                    lb = mid;
                } else {
                    ub = mid;
                }
            }
            return false;
        }

        int lcp( int x, int y ) {
            int l = n - std::min( x, y );
            for ( int i = 0; i < l; ++ i )
                if ( s[x+i] != s[y+i] )
                    return i;
            return l;
        }

        void buildHeight() {
            int h = 0;
            for ( int i = 0; i < n; ++ i ) {
                int j = rank[i];
                if ( j == n - 1 ) { h = 0; continue; }
                int k = sa[j+1];
                if ( h > 0 ) h = h - 1 + lcp( i + h - 1, k + h - 1 );
                else h = lcp( i, k );
                height[j] = h;
            }
        }
    };
}

// @snippet<sh19910711/contest:tree/interface_segment_tree.cpp>
namespace tree {
    template <class T> class ISegmentTree {
    public:
        virtual void init( int n ) {}
        virtual void update( int k, T a ) = 0;
    };
}

// @snippet<sh19910711/contest:tree/rmq_tree.cpp>
namespace tree {
    template <class T> class RMQTree: public tree::ISegmentTree<T> {
    public:
        T INF;
        int n;
        std::vector<T> D;
        RMQTree(): INF( std::numeric_limits<T>::max() ) { n = 0; }
        RMQTree( int n_ ): INF( std::numeric_limits<T>::max() ) {init(n_);}
        void init( int n_ ) {
            n = 1;
            while ( n < n_ ) n *= 2;
            D.resize( 2 * n - 1 );
            for ( int i = 0; i < 2 * n - 1; ++ i ) D[i] = INF;
        }
        int parent( const int k ) { return ( k - 1 ) / 2; }
        int left( const int k ) { return 2 * k + 1; }
        int right( const int k ) { return 2 * k + 2; }
        // D[k] = a;
        void update( int k, T a ) {
            k += n - 1, D[k] = a;
            while ( k > 0 ) k = parent(k), D[k] = std::min( D[left(k)], D[right(k)] );
        }
        T query( int a, int b, int k, int l, int r ) {
            if ( r <= a || b <= l ) return INF;
            if ( a <= l && r <= b ) return D[k];
            T vl = query( a, b, left(k), l, ( l + r ) / 2 );
            T vr = query( a, b, right(k), ( l + r ) / 2, r );
            return std::min( vl, vr );
        }
        T query( int a, int b ) { return query( a, b, 0, 0, n ); }
    };
}


// @snippet<sh19910711/contest:solution/solution.cpp>
namespace solution {
    using namespace std;
    string A, B;
    text::SuffixArray sa;
    tree::RMQTree<int> rmq;

    /*
    bool misc_find( const std::string& key ) {
        int lb = -1, ub = n;
        while ( ub - lb > 1 ) {
            int mid = ( lb + ub ) / 2;
            std::string t = s.substr( sa[mid] );
            if ( t.substr( 0, key.size() ) == key ) {
                return true;
            } else if ( t < key ) {
                lb = mid;
            } else {
                ub = mid;
            }
        }
        return false;
    }
    */

    bool find( const string& key ) {
        return sa.find( key );
    }

    class Solution: public ISolution {
    public:
        bool input() {
            return cin >> A >> B;
        }
        int search( string s ) {
            int length = 0;
            int n = s.size();
            rmq.init(n-1);
            for ( int i = 0; i < n - 1; ++ i ) {
                rmq.update( i, sa.height[i] );
            }
            for ( int i = 0; i + length < n; ) {
                if ( find( s.substr( i, length + 1 ) ) ) {
                    length ++;
                } else {
                    i ++;
                }
            }
            return length;
        }
        void solve() {
            sa.init(A);
            sa.build();
            sa.buildHeight();
            cout << search(B) << endl;
        }
        int run() {
            while ( init(), input() ) {
                solve();
                output();
            }
            return 0;
        }
    };
}


// @snippet<sh19910711/contest:main.cpp>

int main() {
    return solution::Solution().run();
}

Measured memory_bytes: 1364