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

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