CodePSU 2019 - Advanced

Start

2019-03-24 09:15 AKDT

CodePSU 2019 - Advanced

End

2019-03-24 13:15 AKDT
The end is near!
Contest is over.
Not yet started.
Contest is starting in -671 days 2:44:16

Time elapsed

4:00:00

Time remaining

0:00:00

Problem F
Library of Babel

Nathan, a lexicographer and linguist, has discovered the mythical Library of Babel, a place that contains all known combinations of letters in the world. The Library consists of two towers. Hoping to find a pattern in the cacophony of meaningless noise, he repeatedly samples a page from both towers and compares the two. However, simply matching a letter or two isn’t enough. Nathan wants to find the largest continuous sequence of letters that is the reverse of another sequence of letters.

Input

The input contains two lines, each of which contain strings of length $n$ ($1 \leq n \leq 1\, 000$). The strings contain only lowercase letters.

Output

Your program should output the length of the longest continuous sequence of letters from the first string that is the reverse of another continuous sequence of letters from the second string.

Sample Input 1 Sample Output 1
abcdefghi
hgfcbdxff
3
Sample Input 2 Sample Output 2
dsxgkylfjpfpplzpdpwqsdtjmqgvwjcaabygfcszumyevqsciz
uxjnzpuyigepzuirrfhjrlaovlosxfszhqfppfpjsdkoqompui
5