#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N,Q = [int(x) for x in input().split()]
slist = list(input())
tlist = []
dlist = []
for _ in range(Q):
    t,d = [x for x in input().split()]
    tlist.append(t)
    dlist.append(d)

glist = []
for _ in range(N):
    glist.append(1)

for i in range(Q):
    t = tlist[i]
    d = dlist[i]
    for j in range(N):
        if slist[j] == t:
            if j == 0 and d == 'L':
                glist[0] = 0
            elif j == N-1 and d == 'R':
                glist[-1] = 0
            else:
                g = glist[j]
                glist[j] = 0
                if d == 'R':
                    glist[j+1] += g
                else:
                    glist[j-1] += g

print(sum(glist))
