n, q = map(int, input().split())
s = list(input())
list =  [list(map(str, input().split())) for _ in range(q)]

for i in range(n):
    cnt1 = i
    char = s[i]
    for j in range(q):
        if char == list[j][0]:
            if list[j][1] == "L":
                cnt1 -= 1
                if cnt1 < 0:
                    break
                else:
                    char = s[cnt1]
            if list[j][1] == "R":
                cnt1 += 1
                if cnt1 > n-1:
                    break
                else:
                    char = s[cnt1]
    if cnt1 >= 0 and cnt1 <= n-1:
        result1 = i
        break

for i in reversed(range(n)):
    cnt2 = i
    char = s[i]
    for j in range(q):
        if char == list[j][0]:
            if list[j][1] == "L":
                cnt2 -= 1
                if cnt2 < 0:
                    break
                else:
                    char = s[cnt2]
            if list[j][1] == "R":
                cnt2 += 1
                if cnt2 > n-1:
                    break
                else:
                    char = s[cnt2]
    if cnt2 >= 0 and cnt2 <= n-1:
        result2 = i
        break

print(result2 - result1 + 1)