N,Q = map(int,input().split())
s = list(input())
#print(s)
for _ in range(Q):
    t,d = input().split()
    if d == 'L':
        for i in range(len(s)):
            if t in s[i]:
                if i == 0:
                    s[0] = ''
                #elif i == N-1:
                #    pass
                else:
                    s[i-1] += s[i]
                    s[i] = ''
    else:
        for i in range(len(s)-1,-1,-1):
            if t in s[i]:
                #if i == 0:
                #    pass
                if i == N-1:
                    s[N-1] = ''
                else:
                    s[i+1] += s[i]
                    s[i] = ''
    #print(s,t,d)
g = 0
for z in s:
    g += len(z)
#print(s)
print(g)