N, Q = map(int, input().split())
d = {'L': -1, 'R': 1}
s = input()
v = []
for i in range(Q):
    a, b = input().split()
    v.append((a, d[b]))


def checkL(x, s):
    for a, b in v:
        if a == s[x]:
            x += b
        if x < 0:
            return True
        if x >= len(s):
            return False


def checkR(x, s):
    for a, b in v:
        if a == s[x]:
            x += b
        if x >= len(s):
            return True
        if x < 0:
            return False


left = -1
l, r = -1, N
while r - l > 1:
    mid = (r + l) // 2
    if checkL(mid, s):
        l = mid
    else:
        r = mid

left = l


right = N
l, r = -1, N
while r - l > 1:
    mid = (r + l) // 2
    if checkR(mid, s):
        r = mid
    else:
        l = mid

right = r

print(max(0, right - left - 1))