N, Q = (int(i) for i in input().split())
S = input()
L = []
for i in range(Q):
    t, d = (i for i in input().split())
    L.append((t,d))

def func(k):
    now = k
    for t, d in L:
        if S[now] == t:
            if d == "R":
                now += 1
            else:
                now -= 1
        if now < 0:
            return "l"
        elif now >= N:
            return "r"
    if now < 0:
        return "l"
    elif now >= N:
        return "r"
    else:
        return None
ans = 0
left = 0
right = N
while True:
    if left >= right:
        break
    opt = (left + right)//2
    if func(opt) == "l":
        left = opt + 1
    else:
        right = opt
ans += right

left = 0
right = N
while True:
    if left >= right:
        break
    opt = (left + right)//2
    if func(opt) == "r":
        right = opt
    else:
        left = opt + 1
ans += (N - left)

print(N - ans)