n ,q = map(int, input().split())
s = input()
golem = [0] + [1] * n +[0]
for i in range(q):
    t_i,d_i = input().split()
    s_i = s
    s_i = s_i.replace(t_i,"1")
    alpha_i =  list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    alpha_i.remove(t_i)
    for al in alpha_i:
        s_i = s_i.replace(al,"0")
    s_i_list = list(s_i)
    s_i_list = [int(a) for a in s_i_list]
    s_i_list =[0] + s_i_list + [0]
    s_i_list = [s_i_list[k] * golem[k] for k in range(n+2)]

    golem = [golem[k]-s_i_list[k] for k in range(n+2)]

    if d_i=="R":
        s_i_list = [0] + s_i_list
        s_i_list = s_i_list[:-1]
    else :
        s_i_list = s_i_list + [0]
        s_i_list = s_i_list[1:]
    golem = [golem[k] + s_i_list[k] for k in range(n+2)]

golem = golem[1:-1]
print(sum(golem))
