N, Q = map(int, input().split())
s = ''.join(['_', input(), '_'])

gc = [1 for i in range(N+2)]
D = dict([(c, []) for c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'])
for i in range(N):
    if s[i] in D.keys():
        D[s[i]].append(i)
    else:
        D[s[i]] = [i]

M = [input().split() for q in range(Q)]

def does_reach(i_start):
    i = i_start
    for m in M:
        t, d = m
        if s[i] != t:
            continue
        if d == "L":
            i -= 1
            if i == 0:
                return -1
        if d == "R":
            i += 1
            if i == N+1:
                return 1
    return 0

left = 0
right = N + 1
mid = (left + right) // 2
while left < right:
    if does_reach(mid) < 0:
        left = mid+1
    else:
        right = mid - 1
    mid = (left + right) // 2
result_l = mid

left = 0
right = N + 1
mid = (left + right) // 2
while left < right:
    if does_reach(mid) > 0:
        right = mid-1
    else:
        left = mid+1
    mid = (left + right) // 2
result_r = mid

print(result_r  - result_l)
