import sys
F = sys.stdin
N, Q = map(int, F.readline().strip("\n").split())
s = F.readline().strip("\n")
O = [None] * Q
for i in range(Q):
    O[i] = list(map(str, F.readline().strip("\n").split()))

leftlow, lefthigh = 0, N
while lefthigh - leftlow > 1:
    mid = (lefthigh + leftlow)//2
    now, nowi = s[mid], mid
    vanishleft = False
    for place, move in O:
        if place == now:
            if move == "L":
                if nowi == 0:
                    vanishleft = True
                    break
                else:
                    now, nowi = s[nowi - 1], nowi - 1
            if move == "R":
                if nowi == N - 1: break
                else: now, nowi = s[nowi + 1], nowi + 1
    if vanishleft:leftlow = mid
    else: lefthigh = mid

rightlow, righthigh = 0, N
while righthigh - rightlow > 1:
    mid = (righthigh + rightlow)//2
    now, nowi = s[mid], mid
    vanishright = False
    for place, move in O:
        if place == now:
            if move == "L":
                if nowi == 0: break
                else:
                    now, nowi = s[nowi - 1], nowi - 1
            if move == "R":
                if nowi == N - 1: 
                    vanishright = True
                    break
                else: now, nowi = s[nowi + 1], nowi + 1
    if vanishright:righthigh = mid
    else: rightlow = mid

print(righthigh - lefthigh)