N,Q = map(int, input().split())
s = input()
s_uni = list(set(list(s)))
s_lis = []
for i in range(len(s_uni)):
    ss = ""
    for j in range(N):
        if s[j] == s_uni[i]:
            ss += "1"
        else:
            ss += "0"
    s_lis.append(ss)


retu = int("1"*N)
cnt = 0

for q in range(Q):
    t,d = map(str,input().split())
    # print(retu)
    for i in range(len(s_uni)):
        if s_uni[i] == t:
            retu2 = ""
            retu_str = "0"*(N-len(str(retu)))+str(retu)
            # print(retu_str)
            for j in range(N):
                retu2 += str(int(s_lis[i][j])*int(retu_str[j]))
            retu2 = int(retu2)


            if d == "L":
                retu -= retu2
                retu += retu2*10
            else:
                retu -= retu2
                retu += int(retu2/10)

                # print(retu)

            if retu >= 10**N:
                over = int(retu/(10**N))
                cnt += over
                retu -= over*(10**N)

            # print(retu)

            break

print(sum(map(int,list(str(retu)))))
