a = [int(each) for each in input().split()]
s = input()

N, Q = a[0], a[1]
remains = N
state = [1] * N

for q in range(Q):
    t = input().split()
    # 対象マスを選定
    for i, st in enumerate(s):
        if st == t[0]:
            golems = state[i]
            state[i] = 0
            if (i == 0 and t[1] == 'L') or (i == N - 1 and t[1] == 'R'):
                remains -= golems
            else:
                if t[1] == 'R':
                    state[i + 1] += golems
                else:
                    state[i - 1] += golems
print(remains)
