n, q = [int(_) for _ in input().split()]
s = [[x, 1] for x in list(input())]


for __ in range(q):
    c, d = input().split()
    r = range(n) if d == 'R' else range(n-1,-1,-1)
    m= 0

    for i in r:
        if s[i][0] == c:
            s[i][1], m = m, s[i][1]
        else:
            s[i][1] += m
            m = 0

ans = 0
for i in range(n):
    ans += s[i][1]
print(ans)
