import sys
import numpy as np

def main():
    input = sys.stdin.readline
    N, Q = map(int, input().split())
    alph = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
            'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']

    pos = [[0]*N for _ in range(26)]
    for i, c in enumerate(input().strip()):
        p = alph.index(c)
        pos[p][i] = 1

    move = []
    for p in pos:
        move.append(np.array(p))

    cur = np.ones(N, dtype=int)
    for _ in range(Q):
        t, d = map(str, input().split())
        p = alph.index(t)
        m = move[p]
        golem = cur * m

        if d == 'L':
            moved_golem = np.append(golem[1:], 0)
        else:
            moved_golem = np.insert(golem[:N-1], 0, 0)

        cur = cur + moved_golem - golem

    print(np.sum(cur))


if __name__ == '__main__':
    main()
