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

t = []
d = []
for i in range(Q):
    t_i, d_i = input().split()
    t.append(t_i)
    d.append(d_i)


def calc_group(n):
    for i in range(Q):
        if s[n] == t[i]:
            if d[i] == 'L':
                n -= 1
                if n == -1:
                    return -1
            elif d[i] == 'R':
                n += 1
                if n == N:
                    return 1
    return 0


l = -1
r = N
n = (l + r) // 2
while l != n:
    if calc_group(n) == -1:
        l = n
    else:
        r = n
    n = (l + r) // 2
l_max = l

l = -1
r = N
n = (l + r) // 2
while l != n:
    if calc_group(n) == 1:
        r = n
    else:
        l = n
    n = (l + r) // 2
r_min = r

if r_min == l_max:
    count = 0
else:
    count = r_min - l_max - 1
print(count)