n,q = map(int,input().split())
S = ['!']+list(input())+['!']
G = [0]+[1]*n+[0]
for i in range(q):
    t,d = input().split()
    if t in S:
        indexes = [j for j,x in enumerate(S) if x == t]
        for ind in indexes:
            if d == 'L':
                G[ind-1] += G[ind]
                G[ind] = 0
            else:
                G[ind+1] += G[ind]
                G[ind] = 0
print(n-G[0]-G[-1])