import sys
input = sys.stdin.readline

def rise(inspell, infield, direc = 0):
    p = 0
    if direc == 1:
        infield = infield[::-1]
        inspell = inspell[1][::-1]
    else:
        inspell = inspell[0][::-1]

    for w in inspell:

        if infield[p+1] == w:
            p += 1
    return p

n, q = [ int(v) for v in input().split() ]
field = "l" + input()[:-1] + "r"
spell = [[],[]]

for i in range(q):
    w, d = input().split()
    if d == "L":
        spell[0].append(w)
    else:
        spell[1].append(w)

left = rise(spell, field)
right = rise(spell, field, 1)
print(max(0,n-left-right))