n,q = map(int,input().split())
s = input()
word = list(s)
li = [list(input().split()) for _ in range(q)]
memo = {}


def dfs(m):
    if m in memo:
        return memo[m]
    for i in range(q):
        if word[m] == li[i][0]:
            if li[i][1] == 'R':
                m += 1
            else:
                m -= 1
        if m < 0:
            memo[m] = 'Left'
            return 'Left'
        elif m > n-1:
            memo[m] = 'Right'
            return  'Right'
    memo[m] = True
    return True

def left(a,b):
    if a == 0 and b == n-1:
        if dfs(a) != 'Left':
            return 0
        elif dfs(b) == 'Left':
            return n
    m = int((a+b)/2)
    if a == m:
        return b
    if dfs(m) == 'Left':
        return left(m,b)
    else:
        return left(a,m)

def right(a,b):
    if a == 0 and b == n-1:
        if dfs(b) != 'Right':
            return n-1
        elif dfs(a) == 'Right':
            return -1
    m = int((a+b)/2)
    if a == m:
        return a
    if dfs(m) == 'Right':
        return right(a,m)
    else:
        return right(m,b)

print(right(0,n-1) - left(0,n-1) + 1)
