N,Q = map(int, input().split())
s = input()
G = [1] * len(s)

IN = [['a','b'] for i in range(Q)]
for i in range(Q):
    t, d = map(str, input().split())
    IN[i] = [t, d]

for i in range(Q):
    t = IN[i][0]
    d = IN[i][1]
    now = 0
    for st in s:
        if st is t:
            if d is 'L' and now != 0:
                G[now-1] += G[now]
                G[now] = 0
            elif d is 'L':
                G[now] = 0
            elif d is 'R' and now != len(s)-1:
                G[now+1] += G[now]
                G[now] = 0
            elif d is 'R':
                G[now] = 0
        now += 1

count = 0
for i in G:
    count += i
print(count)
