[N,Q] = list(map(int,input().split()))
s = str(input())
t = []
d = []
for i in range(Q):
    [t_temp,d_temp] = list(map(str,input().split()))
    t.append(t_temp)
    d.append(d_temp)

def check_golem(ini,s,t,d):
    golem_temp = ini
    for i in range(len(t)):
        if s[golem_temp] == t[i]:
            if d[i] == 'L':
                golem_temp -= 1
            elif d[i] == 'R':
                golem_temp += 1
        if golem_temp >= len(s) or golem_temp < 0:
            golem_temp = 'dame'
            break
    return golem_temp

data = [0]*len(s)
for i in range(len(s)):
    data[i] = check_golem(i,s,t,d)
    
ans = 0
for i in range(len(s)):
    if data[i] == 'dame':
        ans += 1

print(len(s)-ans)