CF164B Ancient Berland Hieroglyphs

Description

Polycarpus enjoys studying Berland hieroglyphs. Once Polycarp got hold of two ancient Berland pictures, on each of which was drawn a circle of hieroglyphs. We know that no hieroglyph occurs twice in either the first or the second circle (but in can occur once in each of them). Polycarpus wants to save these pictures on his laptop, but the problem is, laptops do not allow to write hieroglyphs circles. So Polycarp had to break each circle and write down all of its hieroglyphs in a clockwise order in one line. A line obtained from the first circle will be called $ a $ , and the line obtained from the second one will be called $ b $ . There are quite many ways to break hieroglyphic circles, so Polycarpus chooses the method, that makes the length of the largest substring of string $ a $ , which occurs as a subsequence in string $ b $ , maximum. Help Polycarpus — find the maximum possible length of the desired substring (subsequence) if the first and the second circles are broken optimally. The length of string $ s $ is the number of characters in it. If we denote the length of string $ s $ as $ |s| $ , we can write the string as $ s=s_{1}s_{2}...\ s_{|s|} $ . A substring of $ s $ is a non-empty string $ x=s[a...\ b]=s_{a}s_{a+1}...\ s_{b} $ ( $ 1

Input Format

The first line contains two integers $ l_{a} $ and $ l_{b} $ ( $ 1

Output Format

Print a single number — the maximum length of the common substring and subsequence. If at any way of breaking the circles it does not exist, print 0.

Explanation/Hint

In the first test Polycarpus picks a string that consists of hieroglyphs 5 and 1, and in the second sample — from hieroglyphs 1, 3 and 5.