n, q = map(int, input().split())
s = list(input())
count = []
ans = 0
for i in range(n):
    count.append(1)
for i in range(q):
    x, y = input().split()
    for num, j in enumerate(s):
        if j == x:
            if y == "L" and num != 0:
                count[num - 1] += count[num]
                
            elif y == "R" and num != n - 1:
                count[num + 1] += count[num]
            count[num] = 0   
            



for i in count:
    if i > 0:
        ans += i
print(ans)