N, Q = tuple([int(x) for x in str(input()).split(' ')])

s = input()

direction = {
    'R' : 1,
    'L' : -1,
}

out = [1] * N

for i in range(Q):
    t, d = tuple([x for x in str(input()).split(' ')])
    d_ = direction[d]
    for i, s_ in enumerate(s):
        if s_ == t:
            ii = i + d_
            if ii < N and ii >= 0:
                out[ii] += out[i]
            out[i] = 0

print(sum(out))