def main():
    n, q = map(int, input().split())
    s = input()
    state = [1 for _ in range(n)]
    m = dict()
    for i in range(n):
        if not s[i] in m:
            m[s[i]] = []
        m[s[i]].append(i)

    for _ in range(q):
        t, d = input().split()
        if d == 'L':
            for i in m.get(t, []):
                if i - 1 >= 0:
                    state[i - 1] += state[i]
                state[i] = 0
        else:
            for i in reversed(m.get(t, [])):
                if i + 1 < n:
                    state[i + 1] += state[i]
                state[i] = 0

    print(sum(state))

main()
