# 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_R(command,s,i,N):
            r_ans = i
            break
    # print(r_ans)


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

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

def simulation_R(command,s,now,N):
    for pair in command:
        if pair[0] == s[now]:
            if pair[1] == 'L':
                now -= 1
            elif pair[1] == 'R':
                now += 1
        if now < 0:
            return False
        elif now >= N:
            return True
    return False

def simulation_L(command,s,now,N):
    for pair in command:
        if pair[0] == s[now]:
            if pair[1] == 'L':
                now -= 1
            elif pair[1] == 'R':
                now += 1
        if now < 0:
            return True
        elif now >= N:
            return False
    return False


# 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
#         elif d == 'R' and now >= N :
#             return True
#     return False


if __name__ == "__main__":
    main()