import sys
input = sys.stdin.readline

def fall(p, infield):
    for w, d in spell:
        if infield[p] == w:
            p += d
    return infield[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":
        d = -1
    else:
        d = 1
    spell.append((w,d))

left_fall = 0
left_keep = n+1

while left_keep - left_fall > 1:
    mid = (left_keep + left_fall) // 2
    if fall(mid,field) == "l":
        left_fall = mid
    else:
        left_keep = mid

right_keep = 0
right_fall = n+1

while right_fall - right_keep > 1:
    mid = (right_fall + right_keep) // 2
    if fall(mid,field) == "r":
        right_fall = mid
    else:
        right_keep = mid
right_fall = n+1-right_fall

print(n-left_fall-right_fall)