#P1492C. Maximum width
Maximum width
No submission language available for this problem.
Description
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: of length and of length .
A sequence , where , is called beautiful, if for all from to . The width of a sequence is defined as .
Please help your classmate to identify the beautiful sequence with the maximum width. Your classmate promised you that for the given strings and there is at least one beautiful sequence.
The first input line contains two integers and () — the lengths of the strings and .
The following line contains a single string of length , consisting of lowercase letters of the Latin alphabet.
The last line contains a single string of length , consisting of lowercase letters of the Latin alphabet.
It is guaranteed that there is at least one beautiful sequence for the given strings.
Output one integer — the maximum width of a beautiful sequence.
Input
The first input line contains two integers and () — the lengths of the strings and .
The following line contains a single string of length , consisting of lowercase letters of the Latin alphabet.
The last line contains a single string of length , consisting of lowercase letters of the Latin alphabet.
It is guaranteed that there is at least one beautiful sequence for the given strings.
Output
Output one integer — the maximum width of a beautiful sequence.
Samples
Note
In the first example there are two beautiful sequences of width : they are and .
In the second example the beautiful sequence with the maximum width is .
In the third example there is exactly one beautiful sequence — it is .
In the fourth example there is exactly one beautiful sequence — it is .