n, q = map(int, input().split())
s = input()
td = [input().split() for i in range(q)]
s = "s" + s + "e"

def can_go(i, left=True):
    end = 0 if left else n+1
    if i == end:
        return True
    start = i
    for t, d in td:
        if start == end:
            return True
        if t == s[start]:
            if d == "L":
                start -= 1
            else:
                start += 1
    return start == end

ans = []

left = 0
right = n+1
while right - left > 1:
    center = (left+right)//2
    if can_go(center):
        left = center
    else:
        right = center
ans.append(left)

left = 0
right = n+1
while right - left > 1:
    center = (left+right)//2
    if can_go(center, left=False):
        right = center
    else:
        left = center
ans.append(right)

#print(ans)
print(max(0, ans[1]-ans[0]-1))