n, q = [int(item) for item in input().split()]
s = list(input())
box = [1 for item in range(n)]
for i in range(q):
    t, d = input().split()
    temp = [box[j] if s[j] == t else 0 for j in range(n)]
    temp2 = [box[j] if s[j] != t else 0 for j in range(n)]

    if d == "R":
        # temp = temp[:n - 1]
        temp.insert(0, 0)
    else:
        temp.pop(0)
        temp.append(0)
    box = [temp[j] + temp2[j] for j in range(n)]

count = sum(box)
print(count)