N,Q = map(int,input().split())
s = input()
td = []
count_R = 0
count_L = 0
for i in range(Q):
    td.append(list(input().split()))
    if td[i][1]=='L':
        count_L += 1
    else:
        count_R += 1

count = 0
for i in range(N):
    l = i+1
    r = N-i
    command_L = count_L
    command_R = count_R
    for q in range(Q):
        if (l>command_L and r>command_R) or min(l,r)==0:
            break
        if td[q][0]==s[l-1]:
            if td[q][1]=='R':
                l += 1
                r -= 1
            else:
                l -= 1
                r += 1
        if td[q][1]=='L':
            command_L -= 1
        else:
            command_R -= 1
    if min(l,r)>0:
        count += 1
print(count)