# -*- coding: utf-8 -*-
n1, n2 = map(int, input().split())
s = input()
l = [1] * n1

for i in range(n2):
    ti, di = input().split()
    for j in range(min(int(n1/2),n2)):
        if ti == s[j]:
            if di == 'L':
                if j == 0:
                    l[0]=0
                else:
                    l[j-1] += l[j]
                    l[j] = 0
            else:
                if j == n1-1:
                    l[n1-1]=0
                else:
                    l[j+1] += l[j]
                    l[j] = 0
    for j in range(max(n1-int(n1/2),n1-n2),n1):
        if ti == s[j]:
            if di == 'L':
                if j == 0:
                    l[0]=0
                else:
                    l[j-1] += l[j]
                    l[j] = 0
            else:
                if j == n1-1:
                    l[n1-1]=0
                else:
                    l[j+1] += l[j]
                    l[j] = 0

print(sum(l))
