Question
Char Span
Kael is given a string S and a string T. He must find the length of the longest substring in S that includes only characters found in T.
Input
The first line of the input contains two space-separated integers N, the size of string S and M, the size of string T.
The second line of the input contains a string S of size N.
The third line of the input contains a string T of size M.

Constraints
1 ≤ M ≤ N ≤ 105
All characters in the S and T are lowercase english alphabet letters.
Output
Print the length of the longest substring in string S which contains only the characters that are present in the string T.
Example
Sample Input
5 2
abcbe
cb
Sample Output
3
Explanation
The substring "bcb" is the longest substring in S satisfying the above conditions.

Online