def bisection_L_Method(a, b):
    while a + 1 < b:
        if checkleft(int((a + b) / 2)):
            a = int((a + b) / 2)
        else:
            b = int((a + b) / 2)
    return a

def bisection_R_Method(a, b):
    while a + 1 < b:
        if checkright(int((a + b) / 2)):
            b = int((a + b) / 2)
        else:
            a = int((a + b) / 2)
    return b

def checkleft(num):
    for i in range(q):
        if quel[i][0] == s[num]:
            if quel[i][1] == 'L':
                num -= 1
            else:
                num += 1
        if num == -1:
            return True
        elif num > len(s) - 1:
            return False
    return False

def checkright(num):
    for i in range(q):
        if quel[i][0] == s[num]:
            if quel[i][1] == 'L':
                num -= 1
            else:
                num += 1
        if num == len(s):
            return True
        elif num < 0:
            return False
    return False

n , q = list(map(int,input().split()))
s = input()
quel = []
count = 0
for i in range(q):
    quel.append(list(input().split()))
if  checkleft(0):
    count += bisection_L_Method(0, len(s) - 1) + 1
if  checkright(len(s) - 1):
    count += len(s) - bisection_R_Method(0, len(s) - 1)
print(len(s) - count)