n,q = map(int,input().split())
sl = list(input())

tdl = [list(map(str,input().split())) for _ in range(q)]

def simulate(i):
    if i < 0:
        return 0
    if i > n - 1:
        return 2
    now = sl[i]
    for t, d in tdl:
        if t == now:
            if d == "R":
                i += 1
            else:
                i -= 1
        if i == -1:
            return 0
        if i == n:
            return 2
        now = sl[i]
    return 1
ub = n
lb = -1
while True:
    if ub == lb:
        ans = ub
        break
    target = (ub + lb) // 2 + 1
    if simulate(target) == 0:
        lb = target
    else:
        ub = target - 1

ub = n
lb = -1
while True:
    if ub == lb:
        ans2 = ub
        break
    target = (ub + lb) // 2 + 1
    if simulate(target) == 1:
        lb = target
    else:
        ub = target - 1


print(n-(ans+1+n-ans2-1))

