import string


def solve(N, Q, S, TDs):
    ascii_map = {}
    for s in string.ascii_uppercase:
        ascii_map[s] = int("".join(["0" if c != s else "1" for c in S]), 2)
    ans = 0
    for q in TDs[::-1]:
        t, d = q
        base = 0
        if t == S[0] and d == "L":
            base = 1 << (N-1)
        elif t == S[-1] and d == "R":
            base = 1

        death = ascii_map[t]
        if d == "L":
            death = (ans >> 1) & death
        else:
            death = (ans << 1) & death
        ans = ans | death | base

    return  ("{:0" + str(N) + "b}").format(ans).count("0")

if __name__ == "__main__":
    N, Q = tuple(map(int, input().split(" ")))
    S = input()
    TDs = [tuple(input().split(" ")) for __ in range(Q)]
    print(solve(N, Q, S, TDs))
