N, Q = [int(_) for _ in input().split()]
S = '.' + input() + '.'
TD = [input().split() for _ in range(Q)]


def check(x):
    for t, d in TD:
        if S[x] == t:
            if d == 'L':
                x -= 1
            else:
                x += 1
    if x == 0:
        return -1
    elif x == N + 1:
        return 1
    else:
        return 0


#to_left_end
ok = 0
ng = N + 1

while ng - ok > 1:
    mid = (ok + ng) // 2
    if check(mid) == -1:
        ok = mid
    else:
        ng = mid
l = ok

#to_right_end
ok = N + 1
ng = 0
while ok - ng > 1:
    mid = (ok + ng) // 2
    if check(mid) == 1:
        ok = mid
    else:
        ng = mid
r = ng
print(r - l)

# https://img.atcoder.jp/exawizards2019/editorial.pdf
