# coding: utf-8
def main():
    N,Q = map(int, input().split())
    s = input()
    ans = N
    command = []

    # print(char_list)

    for i in range(Q):
        # 呪文
        t,d = input().split()
        command.append([t,d])
    r_ans = N
    l_ans = -1
    for i in range(N):
        if simulation(command,s,i,'R',N):
            r_ans = i
            break
    # print(r_ans)


    for i in range(N-1,-1,-1):
        if simulation(command,s,i,'L',N):
            l_ans = i
            break
    # print(l_ans)

    ans = N - (N-r_ans) - (l_ans+1)
    print(ans)


def simulation(command,s,now,d,N):
    # print("test"+str(now))
    for pair in command:
        if pair[0] == s[now]:
            if pair[1] == 'L':
                now -= 1
            elif pair[1] == 'R':
                now += 1
        if d == 'L' and now < 0 :
            return True
        elif d == 'R' and now >= N :
            return True
    return False


def move(Golem_list,d,ans,N,si):
    if d == 'L':
        if si == 0:
            ans -= Golem_list[0]
            Golem_list[0] = 0
        else :
            Golem_list[si-1] += Golem_list[si]
            Golem_list[si] = 0

    elif d == 'R':
        if si == N-1:
            ans -= Golem_list[N-1]
            Golem_list[N-1] = 0
        else :
            Golem_list[si+1] += Golem_list[si]
            Golem_list[si] = 0
    # print(Golem_list)
    # print("#"+str(ans))
    return ans

if __name__ == "__main__":
    main()