N, Q = map(int, input().split())
s = input()
TD = [input().split() for i in range(Q)]


def check(i):
    """どっちに落ちるかを返す
    -1,0,1

    Args:
        i ([type]): [description]
    """

    if i == -1:
        return -1
    if i == N:
        return 1

    for q in range(Q):
        t, d = TD[q]
        if t == s[i]:
            if d == "L":
                i -= 1
            else:
                i += 1

            if i == -1:
                return -1
            if i == N:
                return 1
    return 0


s_index = -1  # include
e_index = N  # include
while s_index+1 < e_index:
    c_index = (s_index+e_index)//2
    if check(c_index) == -1:
        s_index = c_index
    else:
        e_index = c_index
left = s_index

s_index = -1  # include
e_index = N  # include
while s_index+1 < e_index:
    c_index = (s_index+e_index)//2
    if check(c_index) == 1:
        e_index = c_index
    else:
        s_index = c_index
right = e_index


print(right-left-1)
