N, Q = map(int, input().split())
s = input()
lst = [1] * N
for _ in range(Q):
    t, d = input().split()
    lst2 = [0] * N 
    lst3 = [0] * N 
    for idx, x in enumerate(s):
        tmp = lst[idx]   
        if x == t and tmp > 0:
            lst2[idx] = -1 * tmp
            if d == 'R':
                if idx + 1 < N:
                    lst3[idx + 1] = tmp
            else:        
                if idx > 0:
                    lst3[idx - 1] = tmp
                    
    for i, t in enumerate(zip(lst, lst2, lst3)):
        lst[i] = sum(t)

print(sum(lst))