n, q = map(int,input().split())
s = input()
a = [1 for i in range(len(s))]
for i in range(q):
    moj, mov = input().split()
    for j in range(len(s)):
        if s[j] == moj:
            if mov == "L":
                if j == 0:
                    a[j] = 0
                else:
                    a[j-1]+=a[j]
                    a[j] = 0
            if mov == "R":
                if j == n-1:
                    a[j] = 0
                else:
                    a[j+1]+=a[j]
                    a[j] = 0
print (sum(a))
