[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 move_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 == -1 or golem_temp == len(s):
            break
    return golem_temp

# check lower bound

def check_lower(s,t,d):
    lb = -1
    ub = len(s)
    while ub - lb > 1:
        mid = (lb + ub)//2
        mid_golem_temp = move_golem(mid,s,t,d)
        if mid_golem_temp == -1:
            lb = mid
        elif mid_golem_temp != -1:
            ub = mid
            
    return lb

def check_upper(s,t,d):
    lb = -1
    ub = len(s)
    while ub - lb > 1:
        mid = (lb + ub)//2
        mid_golem_temp = move_golem(mid,s,t,d)
        if mid_golem_temp == len(s):
            ub = mid
        elif mid_golem_temp != len(s):
            lb = mid
            
    return ub

print(check_upper(s,t,d)-check_lower(s,t,d)-1)