n, q = map(int, input().split())
s = input()
li = [list(input().split()) for _ in range(q)]
l, r = 0, n
while r - l > 1:
    m = (l + r) // 2
    i = m
    for t, d in li:
        if i < n and s[i] == t:
            if d == 'L':
                i -= 1
            else:
                i += 1
        if i < 0:
            l = m
            break

    else:
        r = m
ans1 = r
l, r = 0, n
while r - l > 1:
    m = (l + r) // 2
    i = m
    for t, d in li:
        if s[i] == t:
            if d == 'L':
                i -= 1
            else:
                i += 1
        if i >= n:
            r = m
            break
    else:
        l = m
ans2 = l
print(max(0, ans2 - ans1 + 1))
