N,Q = map(int,input().split())
S = input()
cell = [1 for i in range(N)]
for i in range(Q):
    t,d = input().split()
    if d=='L':
        for i in range(N):
            if S[i]!=t:
                continue
            else:
                if cell[i]==0:
                    continue
                if i==0:
                    cell[i]=0
                else:
                    cell[i-1]+=cell[i]
                    cell[i]=0
    else:
        for i in range(N-1,-1,-1):
            if S[i]!=t:
                continue
            else:
                if cell[i]==0:
                    continue
                if i==N-1:
                    cell[i]=0
                else:
                    cell[i+1]+=cell[i]
                    cell[i]=0
print(sum(cell))
