Round words#7481

Round words

1 second
64 megabytes
Very hard

After the recent apocalypse, Azamat, finally, learned about the longest common subsequence of two strings and now he is interested, what will be the longest common subsequence of two round words?

In a round word there is no difference from which symbol the word starts and in which direction it is read. For instance, the round word algorithm can be read as rithmalgo and as oglamhtir.

For usual words algorithm and grammar the longest common subsequence length is (the word grm), and for round variant of the same word the length of the longest common subsequence is (the word grma).

Azamat quickly found out that the standard algorithm cannot get right answer for round words. Write the program which will do that for him.

Input

Two lines contain one word each. Words are non-empty and the length of each word doesn't exceed characters.

Output

The single line must contain one integer number - the length of the longest common subsequence of the given round words.

Examples

Example 1

Loading
Loading