def is_OK(index):
    res = False
    for t, d in e:
        if t == s[index]:
            if d == 'R':
                index += 1
                if index == N:
                    res = True
                    break
            else:
                index -= 1
                if index == -1:
                    res = True
                    break
    return res


N, Q = map(int, input().split())
s = input()

e = [input().split() for _ in range(Q)]
# t: 文字 <- siと比較
# d: 'L', 'R'

ans = N

# left
ng = N
ok = -1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_OK(mid):
        ok = mid
    else:
        ng = mid
ans -= ok + 1

# right
ng = -1
ok = N
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_OK(mid):
        ok = mid
    else:
        ng = mid
ans -= (N - ok)

print(ans)
