n, q = map(int, input().split())
s = input()

o = []
for _ in range(q):
    t, d = input().split()
    o.append((t, d))


def check(x):
    cur = s[x]
    ind = x
    for i in range(q):
        if o[i][0] == cur:
            if o[i][1] == 'L':
                ind -= 1
                if ind < 0:
                    return "LEFT"
                cur = s[ind]
            else:
                ind += 1
                if ind > n-1:
                    return "RIGHT"
                cur = s[ind]
    return "MID"


ans = n

bottom = -1
top = n

while top - bottom > 1:
    mid = (top+bottom)//2
    if check(mid) == "LEFT":
        bottom = mid
    else:
        top = mid

ans -= 1+bottom

bottom = -1
top = n

while top - bottom > 1:
    mid = (top+bottom)//2
    if check(mid) == "RIGHT":
        top = mid
    else:
        bottom = mid

ans -= n-top

print(ans)