N, Q = map(int, input().split())
s = input()

char_map = [[] for i in range(26)]
for i in range(len(s)):
    char_map[ord(s[i])-65].append(i)

golems = []
for n in range(N):
    golems.append(1)

for q in range(Q):
    t, d = input().split()
    map_index = ord(t) - 65

    if d == 'L':
        for mass in char_map[map_index]:
            if mass != 0:
                golems[mass - 1] += golems[mass]
            golems[mass] = 0
    else:
        for mass in reversed(char_map[map_index]):
            if mass != N-1:
                golems[mass + 1] += golems[mass]
            golems[mass] = 0

print(sum(golems))
