N, Q = list(map(int, input().split()))
s = input()
s_n = [1 for i in range(N)]
for i in range(Q):
    t, d = input().split()
    if d == "L":
        for j in range(N):
            if s[j] == t and j == 0:
                s_n[j] = 0
            elif s[j] == t:
                s_n[j-1] += s_n[j]
                s_n[j] = 0
    else:
        for j in range(N)[::-1]:
            if s[j] == t and j == N-1:
                s_n[j] = 0
            elif s[j] == t:
                s_n[j+1] += s_n[j]
                s_n[j] = 0
print(sum(s_n))     
