#include <bits/stdc++.h>
using namespace std;


class suffix_array {
public:
    suffix_array(std::string const& s_)
        : length(s_.length()),
          s(s_),
          sa(s.length() + 1),
          rank(s.length() + 1)
    {
        for(int i = 0; i <= length; ++i) {
            sa[i] = i;
            rank[i] = i < length ? s[i] : -1;
        }
        int k = 0;
        auto compare_sa = [this, &k](int i, int j) {
            if(rank[i] != rank[j]) {
                return rank[i] < rank[j];
            } else {
                int ri = i + k <= length ? rank[i + k] : -1;
                int rj = j + k <= length ? rank[j + k] : -1;
                return ri < rj;
            }
        };
        for(k = 1; k <= length; k *= 2) {
            sort(sa.begin(), sa.end(), compare_sa);

            std::vector<int> tmp(length + 1);
            tmp[sa[0]] = 0;
            for(int i = 1; i <= length; ++i) {
                tmp[sa[i]] = tmp[sa[i - 1]] + (compare_sa(sa[i - 1], sa[i]) ? 1 : 0);
            }
            for(int i=0; i <= length; ++i) {
                rank[i] = tmp[i];
            }
        }
    }

    std::vector<int> get() const {
        return sa;
    }

    std::string get_string() const {
        return s;
    }

    bool contain(std::string const& t) {
        int l = 0, r = length;
        while(r - l > 1) {
            int m = (l + r) / 2;
            if(s.compare(sa[m], t.length(), t) < 0) {
                l = m;
            } else {
                r = m;
            }
        }
        return s.compare(sa[r], t.length(), t) == 0;
    }

    int lower_bound(std::string const& t) {
        int l = 0, r = length + 1;
        while(r - l > 1) {
            int m = (l + r) / 2;
            if(s.compare(sa[m], std::string::npos, t) < 0) {
                l = m;
            } else {
                r = m;
            }
        }
        return r;
    }
    int upper_bound(std::string const& t) {
        int l = 0, r = length + 1;
        while(r - l > 1) {
            int m = (l + r) / 2;
            if(s.compare(sa[m], t.size(), t) <= 0) {
                l = m;
            } else {
                r = m;
            }
        }
        return r;
    }

private:
    int length;
    std::string s;
    std::vector<int> sa;
    std::vector<int> rank;
};


std::vector<int> construct_lcp(suffix_array const& SA) {
    auto s = SA.get_string();
    const int n = s.size();
    auto sa = SA.get();
    std::vector<int> rank(n + 1);
    for(int i = 0; i <= n; ++i) {
        rank[sa[i]] = i;
    }

    int h = 0;
    std::vector<int> lcp(n);
    for(int i = 0; i < n; ++i) {
        int j = sa[rank[i] - 1];

        if(h > 0) {
            h--;
        }
        for(; j + h < n && i + h < n; ++h) {
            if(s[j + h] != s[i + h]) {
                break;
            }
        }
        lcp[rank[i] - 1] = h;
    }

    return lcp;
}

int main() {
    string s, t;
    while(cin >> s >> t) {
        const int s_len = s.size();
        s += "$" + t;
        suffix_array SA(s);
        auto sa = SA.get();
        auto lcp = construct_lcp(SA);

        int res = 0;
        for(int i = 0; i < s.size(); ++i) {
            if((sa[i] < s_len) != (sa[i + 1] < s_len)) {
                res = max(res, lcp[i]);
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3244