LogiQuest

234. Longest Common Substring

MediumDynamic Programming

Print the length of the longest string that is a contiguous substring of both a and b.

Input format

Line 1: a Line 2: b

Output format

The length.

Example 1

Input

abcdxyz
xyzabcd

Output

4

Example 2

Input

zxabcdezy
yzabcdezx

Output

6

Constraints

1 ≤ |a|, |b| ≤ 2000

Read input from standard input and print the answer to standard output. Your code is judged against 6 test cases, most of them hidden.

Loading the MyLoginn IDE…