#t198. 字符环

字符环

Longest Common Substring on Two Rings

Problem Description

There are two rings made of characters. Write a program to compute the length of the longest contiguous common substring on these two character rings. For example, the string ABCEFAGADEGKABUVKLM with its ends joined forms one ring; the string MADJKLUVKL with its ends joined forms another ring; UVKLMA is a contiguous common substring of the two rings.

Input Format

One line containing two strings, corresponding to the two character rings, separated by a single space. Each string has length at most 255255 and contains no whitespace.

Output Format

Output one integer: the length of the longest common substring on the two rings.

Sample Input

ABCEFAGADEGKABUVKLM MADJKLUVKL

Sample Output

6