n,q = map(int,input().split())
s = input()
query = [list(map(str,input().split())) for _ in range(q)]
def sim(x):
    now = s[x]
    for i in range(q):
        t,d = query[i][0],query[i][1]
        if now != t:
            continue
        if d == "L":
            x -= 1
            if x == -1:
                return -1
        else:
            x += 1
            if x == n:
                return 1
        now = s[x]
    return 0

max_left = -1
min_right = n
min_safe = n
max_safe = -1
save = (max_left, min_right)
flag = 0
while (min_right-max_left) > 1:
    m = (max_left+min_right)//2
    j = sim(m)
    if j == -1:
        max_left = m
    if j == 0:
        max_safe = max(max_safe, m)
        min_safe = min(min_safe, m)
    if j == 1:
        min_right = m
    
    if (max_left, min_right) != save:
        save = (max_left, min_right)
    else:
        #left
        #print(max_left, min_safe, max_safe, min_right)
        l,r = max_left, min_safe
        while (r-l) > 1:
            m = (r+l)//2
            j = sim(m)
            if j == -1:
                l = m
            elif j == 0:
                r = m
        max_left, min_safe = l,r
        #right
        l,r = max_safe, min_right
        while (r-l) > 1:
            m = (r+l)//2
            j = sim(m)
            if j == 0:
                l = m
            elif j == 1:
                r = m
        max_safe, min_right = l,r

        flag = 1
        break
if flag:
    print(max_safe-min_safe+1)
else:
    print(0)