n, q = [int(item) for item in input().split()]
s = input().rstrip()
td = [[item for item in input().split()] for _ in range(q)]

ans = n
l = -1; r = n
for t, d in td[::-1]:
    if d == "L":
        if t == s[l+1]:
            l += 1
    else:
        if(l > 0):
            if t == s[l-1]:
                l -= 1
    if d == "R":
        if t == s[r-1]:
            r -= 1
    else:
        if(r < n-1):
            if t == s[r+1]:
                r += 1
    ans = min(ans, r - l - 1)
    # Run out golems
    if l == n-1 or r == 0:
        print(0)
        exit()
if ans > 0:
    print(ans)
else:
    print(0)