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