
def move_left(golem, string, t, d):
    if string[0] == t:
        num_out = golem[0]

    new_golem = [0] * len(golem)
    for i in range(len(golem)):
        if string[i] != t:
            new_golem[i] = golem[i]

    for i in range(1, len(golem)):
        if string[i] == t:
            new_golem[i-1] += golem[i]
    return new_golem

def move_right(golem, string, t, d):
    if string[-1] == t:
        num_out = golem[-1]

    new_golem = [0] * len(golem)
    for i in range(len(golem)):
        if string[i] != t:
            new_golem[i] = golem[i]

    for i in range(0, len(golem) - 1):
        if string[i] == t:
            new_golem[i+1] += golem[i]
    return new_golem

def main():
    N, Q = list(map(int, input().split()))
    string = input()
    t_list, d_list = [], []
    for _ in range(Q):
        t, d = input().split()
        t_list.append(t)
        d_list.append(d)

    golem = [1]*N
    for t, d in zip(t_list, d_list):
        if d == 'L':
            golem = move_left(golem, string, t, d)
        else:
            golem = move_right(golem, string, t, d)

    print(sum(golem))

main()
