n,q = (int(i) for i in input().split())
s = input()
a = {}
for i in range(n):
    if not s[i] in a:
        a[s[i]] = [i]
    else:
        a[s[i]].append(i)

nums = [1] * n
for i in range(q):
    td = list(input().split())
    t = td[0]
    d = td[1]
    if t in a:
        ids = a[t]
        for id in ids:
            if d == 'L':
                if id == 0:
                    nums[id] = 0
                else:
                    nums[id-1] += nums[id]    
                    nums[id] = 0
            else:
                if id == n-1:
                    nums[id] = 0
                else:
                    nums[id+1] += nums[id]
                    nums[id] = 0

print(sum(nums))