n, q = map(int, input().split())
s = input()

query = [list(input().split()) for _ in range(q)]

# 左に落ちる (1から, leftで判断(leftは落ちる個数))
left = 0
right = n+1
while right - left > 1:
    mid = (left + right) // 2
    index = mid - 1
    for w, dir in query:
        if s[index] != w:
            continue
        if dir == 'R':
            index += 1
        elif dir == 'L':
            index -= 1

        if index == n:
            right = mid
            break
        elif index == -1:
            left = mid
            break
    if index != -1:
        right = mid
c1 = left

# 右 (leftで判断(leftが落ちないギリギリ。最大はn-1, 最小は-1))
left = -1
right = n+1
while right - left > 1:
    mid = (left + right) // 2
    index = mid
    for w, dir in query:
        if s[index] != w:
            continue
        if dir == 'R':
            index += 1
        elif dir == 'L':
            index -= 1

        if index == n:
            right = mid
            break
        elif index == -1:
            left = mid
            break
    if index != n:
        left = mid

c2 = n - 1 - left

print(n - c1 - c2)
