N, Q = map(int, input().split())

s_list = [str for str in input()]

num_each_trout = [1 for i in range(N)]

for i in range(Q):
    t, d = input().split()

    if d == "L":
        for k in [j for j, s in enumerate(s_list) if s == t]:
            if k == 0:
                num_each_trout[k]=0
            else:
                num_each_trout[k-1]+=num_each_trout[k]
                num_each_trout[k]=0
    else:
        for k in reversed([j for j, s in enumerate(s_list) if s == t]):
            if k == N-1:
                num_each_trout[k]=0
            else:
                num_each_trout[k+1]+=num_each_trout[k]
                num_each_trout[k]=0

print(sum(num_each_trout))
