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

for i in range(Q):
    char_move, direction = input().split()
    
    if (direction == 'L') & (s[0] == char_move):
        golem_cnt[0] = 0
    elif (direction == 'R') & (s[-1] == char_move):
        golem_cnt[-1] = 0
        
    temp_golem_cnt = golem_cnt
    for j, char in enumerate(s):
        if j == 0 or j == N-1:
            continue
        if char != char_move:
            continue
        if direction == 'L':
            if golem_cnt[j] > 0:
                temp_golem_cnt[j - 1] += temp_golem_cnt[j]
                temp_golem_cnt[j] = 0
        else:
            if golem_cnt[j] > 0:
                temp_golem_cnt[j + 1] += temp_golem_cnt[j]
                temp_golem_cnt[j] = 0
    golem_cnt = temp_golem_cnt

print(sum(golem_cnt))