n, q = map(int,input().split())
s = input()
AL = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

a = [[] for _ in range(26)]
for i, b in enumerate(s):
    a[AL.index(b)].append(i)

for i in range(q):
    t, d = input().split()    
    ti = AL.index(t)
    if d == 'L':
        for j in range(len(a[ti])):
            a[ti][j] -= 1
            
        s0 = AL.index(s[0])
        while a[s0]:
            if a[s0][0] == -1:
                a[s0].pop(0)
            else:
                break
    else:
        for j in range(len(a[ti])):
            a[ti][j] += 1
    
        sl = AL.index(s[-1])
        while a[sl]:
            if a[sl][-1] == n:
                a[sl].pop()
            else:
                break

    for m in range(len(a[ti])):
        for j, k in enumerate(a[ti]):
            if s[k] != t:
                a[AL.index(s[k])].append(k)
                a[ti].pop(a[ti].index(k))
                break

cnt = 0
for az in a:
    cnt += len(az)
print(cnt)