Safe

No attempts yetTime limit1sMemory limit128 MB

Problem

Byteman keeps all of his savings in an old safe. The lock of this safe consists of nn identical wheels, and every wheel has the same word of mm letters written around it. The wheels turn independently, so each one can be set to any of its mm positions. The safe opens when, at every one of the mm positions, all wheels show the same letter, that is, when all wheels display exactly the same word.

Turning any single wheel by 360/m360/m degrees to the left or to the right takes one second. Compute the minimum total time needed to open the safe.

Input

The first line contains two integers nn and mm, separated by a single space (2n,m10000002 \le n, m \le 1\,000\,000): the number of wheels in the lock and the length of the word written on each wheel.

The second line contains the word s1s2sms_1 s_2 \dots s_m of length mm, consisting of uppercase English letters.

The third line contains nn integers o1,o2,,ono_1, o_2, \dots, o_n, separated by single spaces (0oi<m0 \le o_i < m). The value oi=ko_i = k means that wheel ii is rotated kk positions to the left from a fixed reference position, so it currently shows sk+1sk+2sms1s2sks_{k+1} s_{k+2} \dots s_m s_1 s_2 \dots s_k. For example, oi=0o_i = 0 means wheel ii is not rotated at all.

Output

Print one integer: the minimum number of seconds required to open the safe.

Hint

A left rotation and a right rotation by one position are opposite moves. Suppose a wheel currently shows the word OWIKSL. Turning it one position to the left gives WIKSLO, while turning it one position to the right gives LOWIKS. Two wheels count as aligned only when the words they display are identical, so if the word has a repeating structure, several different rotations can produce the same display.