# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def judge(pos, direction):
    for t,d in NLIST:
        if S[pos] != t:
            continue
        if d == 'L':
            pos -= 1
            if pos <= 0 and direction == 'left':
                return True
        else:
            pos += 1
            if pos >= N and direction == 'right':
                return True
    return False

N,Q = map(int, input().split(' '))
S = input(0)
NLIST = []
for i in range(Q):
    t,d = input().split(' ')
    NLIST.append((t,d))

s = 0
e = len(S) - 1
mid = (s + e) // 2
while True:
    flag = judge(mid, 'left')
    if flag:
        s = mid
        mid = (mid + e) // 2
    else:
        e = mid
        mid = (mid + s) // 2
    if e == mid or s == mid:
        if flag:
            res_l = mid
        else:
            res_l = mid - 1
        break
# right
s = 0
e = len(S) - 1
mid = (s + e) // 2
while True:
    flag = judge(mid, 'right')
    if flag:
        s = mid
        mid = (mid + s) // 2
    else:
        e = mid
        mid = (mid + e) // 2
    if e == mid or s == mid:
        if flag:
            res_r = mid
        else:
            res_r = mid + 1
        break

print( res_r - res_l + 1 )
~