N,Q=map(int,input().split())
s=input()
gmap = [1]*N
ans = N
for i in range(Q):
    t,d = map(str,input().split())

    for j in range(N):
        if s[j]==t:
            idou=0
            if d == 'L':
                if gmap[j]>0:
                    idou = gmap[j]
                    gmap[j] = 0
                    if j-1 >= 0:
                        gmap[j-1] += idou
                    else:
                        ans = ans-idou
            else:
                if gmap[j]>0:
                    idou = gmap[j]
                    gmap[j] = 0
                    if j+1 < N:
                        gmap[j+1] += idou
                    else:
                        ans = ans-idou

print(ans)