N, Q = map(int, input().split())
s = input()
t = []
d = []
for i in range(Q):
    j, k = input().split()
    t.append(j)
    d.append(k)
l = 0
r = N - 1
for i in range(Q):
    if d[-i-1] == 'L' and s[l] == t[-i-1]:
        l += 1
    if d[-i-1] == 'R' and s[r] == t[-i-1]:
        r -= 1
    if l > r:
        break
print(max(0, r - l + 1))