N, Q = map(int, input().split())
s = input()

action=[]
for i in range(Q):
    t, d = input().split()
    action.append((t,d))

data = [1]*len(s)
toID = {}
for i, it in enumerate(s):
    if it not in toID.keys():
        toID[it] = []
    toID[it].append(i)


for ac in action:
    t, d = ac
    
    if not t in toID.keys():
        continue
    
    new_data = [0]*len(s)
    # minus
    for index in toID[t]:
        new_data[index] = data[index]
        data[index] = 0

    # plus
    for index in toID[t]:
        if d == 'R' and index < len(s)-1:
            data[index+1] += new_data[index]
        elif d == 'L' and index > 0:
            data[index-1] += new_data[index]
    
print(sum(data))