N, Q = map(int, input().split())
s = input()
g = [1 for _ in range(N)]
p = [i for i in range(N)]

for _ in range(Q):
    t, d = input().split()
    new_g = []
    new_p = []
    for i in range(len(g)):
        if s[p[i]] == t:
            if d == 'R':
                place = p[i] + 1
                if place < N:
                    if place in new_p:
                        new_g[new_p.index(place)] += g[i]

                    else:
                        new_g.append(g[i])
                        new_p.append(place)

            else:
                place = p[i] - 1
                if place >= 0:
                    if place in new_p:
                        new_g[new_p.index(place)] += g[i]

                    else:
                        new_g.append(g[i])
                        new_p.append(place)

        else:
            if p[i] in new_p:
                new_g[new_p.index(p[i])] += g[i]

            else:
                new_g.append(g[i])
                new_p.append(p[i])

    
    g = new_g
    p = new_p

print(sum(g))
