← Home
write a go solution for Description:
Recently, Norge found a string s=s_1s_2ldotss_n consisting of n lowercase Latin letters. As an exercise to improve his typing speed, he decided to type all substrings of the string s. Yes, all n(n+1)/2 of them!

A substring of s is a non-empty string x=s[aldotsb]=s_as_a+1ldotss_b (1<=a<=b<=n). For example, "auto" and "ton" are substrings of "automaton".

Shortly after the start of the exercise, Norge realized that his keyboard was broken, namely, he could use only k Latin letters c_1,c_2,ldots,c_k out of 26.

After that, Norge became interested in how many substrings of the string s he could still type using his broken keyboard. Help him to find this number.

Input Format:
The first line contains two space-separated integers n and k (1<=n<=2*10^5, 1<=k<=26) — the length of the string s and the number of Latin letters still available on the keyboard.

The second line contains the string s consisting of exactly n lowercase Latin letters.

The third line contains k space-separated distinct lowercase Latin letters c_1,c_2,ldots,c_k — the letters still available on the keyboard.

Output Format:
Print a single number — the number of substrings of s that can be typed using only available letters c_1,c_2,ldots,c_k.

Note:
In the first example Norge can print substrings s[1ldots2], s[2ldots3], s[1ldots3], s[1ldots1], s[2ldots2], s[3ldots3], s[5ldots6], s[6ldots7], s[5ldots7], s[5ldots5], s[6ldots6], s[7ldots7].. Output only the code with no comments, explanation, or additional text.