# 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(command)
    r = binary_serch_R(command,s,N)
    #print(r)
    l = binary_serch_L(command,s,N)
    #print(l)
    ans = ans - (N-r) - (l+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 binary_serch_R(command,s,N):
    left = 0
    right = N-1
    if simulation_R(command,s,left,N) :
        return -1
    if simulation_R(command,s,right,N) == False:
        return N


    while not simulation_R(command,s,left,N) and simulation_R(command,s,right,N):
        mid = int((left+right)/2)
        # print(mid)
        if right - left == 1:
            return right
        if simulation_R(command,s,mid,N) :
            right = mid
        else :
            left = mid 
    return right

def binary_serch_L(command,s,N):
    left = 0
    right = N-1
    if simulation_L(command,s,left,N) == False :
        return -1
    if simulation_L(command,s,right,N):
        return N
        
    while simulation_L(command,s,left,N) and (not simulation_L(command,s,right,N)):
        mid = int((left+right)/2)
        if right - left == 1:
            return left
        if not simulation_L(command,s,mid,N) :
            right = mid
        else :
            left = mid 
    return left

# 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()