Finally, Harry Potter was able to invent a spell to defeat his great enemy, Malfoy!…
- User
Finally, Harry Potter was able to invent a spell to defeat his great enemy, Malfoy! Harry made a pair of circular power bracelets that fit on his right and left wrists. On each bracelet he inscribed a sequence of magical letters, each active letter increasing his power almost as much as a beating willow! However, there is a problem. Bracelets only work if the subsequence of activated letters is the same on both bracelets. For example, in the figure below, a pair of bracelets are given, which have two strings of letters a b a b d c b c c ababdcbcc and a a b d c c c c b d aabdccccbd are superimposed on them as magical letters, an optimal activation of which gives Harry as much power as 14 willow bats.
Description of the image
On the first bracelet of the letters b a b d c c c babdccc is activated in clockwise direction and on the second bracelet the same letters are activated in anti-clockwise direction. In general, the order of the letters is important, but the direction under the active sequence on each bracelet (clockwise or counterclockwise) may or may not be the same. Don't forget that bracelets are circular! You must help Harry decide what optimal subsequence of letters on his bracelets he needs to activate in order to defeat Malfoy.
input The input file contains a maximum of 100 input samples. (Maximum contains 5 large patterns) Each pattern is a line consisting of a pair of strings separated by a space, corresponding to the same sequence of letters on Harry's left and right power bracelets (respectively), and each string consists of lowercase letters only. became. The length of each input string between 1 1 to 100 100 characters except in large examples where the length of each input string is between 1 1 to 1500 It is 1500 characters.
output Print the maximum power that Harry can reach by activating the letters on the bracelets (in units of Willow Beater).
Example Sample entry 1 ababdcbcc aabdccccbd harrypotter plorppothaa potterharry plorppothaa Plain text Sample output 1 14 12 12 c++
- Assistant