N,Q = map(int,input().split())
s = [[i,1] for i in input()]
td = []
for i in range(Q):
    td.append(list(input().split()))
#
count = 0
for n in range(N):
    target = n
    for i in td:
        if i[0]==s[target][0]:
            if i[1]=='L':
                target -= 1
            else:
                target += 1
        if target<0 or target>=N:
            break
    if 0 < target and target < N:
        count += 1
print(count)
#