# -*- coding: utf-8 -*-

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

Q_list = []
for i in range(Q):
    Q_list.append(list(input().split()))

drop = 0
for i in range(N):
    #現在の位置
    now_i = i
    now_s = s[now_i]
    for query in Q_list:
        if now_s == query[0]:
            if query[1] == 'L':
                now_i -= 1
                if now_i < 0:
                    drop += 1
                    break
                now_s = s[now_i]
            else:
                now_i += 1
                if now_i >= N :
                    drop += 1
                    break
                now_s = s[now_i]
print(N - drop)