n, q = map(int, input().split())
s = input()
td = []
for i in range(q):
    td.append(list(input().split()))

result = [0] * n
start = 0
end = n-1
flag = True
while flag == True:
    test = (start + end + 1) // 2
    present = test
    for i in range(q):
        if s[present] == td[i][0]:
            if td[i][1] == "L":
                if present == 0:
                    if result[test] == "left":
                        flag = False
                    else:
                        result[test] = "left"
                        start = test
                        break
                else:
                    present -= 1
            if td[i][1] == "R":
                if present == n-1:
                    if result[test] == "right":
                        flag = False
                    else:
                        result[test] = "right"
                        end  = test
                        break
                else:
                    present += 1
    else:
        if result[test] == "center":
            flag = False
        else:
            result[test] = "center"
            end = test
left_end = test

start = 0
end = n-1
flag = True
while flag == True:
    test = (start + end + 1) // 2
    present = test
    for i in range(q):
        if s[present] == td[i][0]:
            if td[i][1] == "L":
                if present == 0:
                    if result[test] == "left":
                        flag = False
                    else:
                        result[test] = "left"
                        start = test
                        break
                else:
                    present -= 1
            if td[i][1] == "R":
                if present == n-1:
                    if result[test] == "right":
                        flag = False
                    else:
                        result[test] = "right"
                        end  = test
                        break
                else:
                    present += 1
    else:
        if result[test] == "center":
            flag = False
        else:
            result[test] = "center"
        start = test
right_end = test
print(right_end - left_end + 2)