n,q = map(int,input().split())

s = input()

m = [list(map(str,input().split())) for i in range(q)]

l = [0]

for i in range(n):
    l.append(1)

l.append(0)

for j in range(q):
    for i in range(n):
        if m[j][0] == s[i]:
            if m[j][1] == 'R':
                l[i+2] += l[i+1]
                l[i+1] = 0
            
            else:
                l[i] += l[i+1]
                l[i+1] = 0
        
                
c = 0

for i in range(1,n+1):
    c += l[i]
    
print(c)