import sys
from collections import defaultdict
from string import ascii_uppercase
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N,Q = read_int()
s = read_str()
td = [list(read_str().split()) for _ in range(Q)]
d = defaultdict(list)
for a in ascii_uppercase:
    d[a] = []
for i in range(N):
    d[s[i]].append(i)
d = dict(d)
lr = {"L":-1, "R":1}

dp = [1 for _ in range(N)]
def solve():
    for i in range(Q):
        char = td[i][0]
        if not d[char]:
            continue

        move = lr[td[i][1]]
        plus = []
        minus = []
        for cur in d[char]:
            if dp[cur] < 1:
                continue
            if cur + move >= 0 and cur + move < N:
                plus.append([cur + move, dp[cur]])
            minus.append([cur, dp[cur]])
        while plus:
            p = plus.pop()
            dp[p[0]] += p[1]
        while minus:
            p = minus.pop()
            dp[p[0]] -= p[1]

if __name__ == "__main__":
    solve()
    print(sum(dp))