# C
n, q = map(int, input().split())
s = str(input())
# 探索に時間がかかってしまうのでindexを保存しておく
l = [[] for i in range(26)]
scount = [1 for i in range(n)]

for index, c in enumerate(list(s)):
    l[ord(c) - ord('A')].append(index)

for i in range(q):
    t, d = map(str, input().split())
    use_list = l[ord(t) - ord('A')]
    if d == 'R':
        use_list = l[ord(t) - ord('A')][::-1]
    for index in use_list:
        if index == 0 and d == 'L':
            scount[index] = 0
        elif index == n-1 and d == 'R':
            scount[index] = 0
        else:
            if d == 'R':
                scount[index+1] += scount[index]
            else:
                scount[index-1] += scount[index]
            scount[index] = 0
ans = sum(scount)
print(ans)