n, q = map(int, input().split())
s = list(input())
sr = list(reversed(s))

t = [0 for k in range(q)]
d = [0 for k in range(q)]
for i in range(q):
    t[i], d[i] = input().split()

stones = [1 for k in range(n)]
for i in range(q):
    if(t[i] in s):
        if(d[i]=='L'):
            tmp = s.index(t[i])
            while(tmp != -1):
                if(tmp==0):
                    stones[0] = 0
                else:
                    stones[tmp-1] += stones[tmp]
                    stones[tmp] = 0
                if (t[i] in s[tmp+1:]):
                    tmp = s.index(t[i], tmp+1)
                else:
                    break
        else:
            tmp = sr.index(t[i])
            while (tmp != -1):
                if (tmp == 0):
                    stones[n-1] = 0
                else:
                    stones[n - tmp] += stones[n - 1 - tmp]
                    stones[n - 1 - tmp] = 0
                if(t[i] in sr[tmp+1:]):
                    tmp = sr.index(t[i], tmp + 1)
                else:
                    break
ans = 0
for i in range(n):
    ans += stones[i]

print(ans)