n, q = map(int, input().split())
s = input()

a = [[s[i], 1] for i in range(n)]

for k in range(q):
    t, d = input().split()
    for i in range(n):
        if a[i][0] == t:
            if d == 'R':
                if i < n - 1:
                    a[i+1][1] += a[i][1]
            else:
                if i > 0:
                    a[i-1][1] += a[i][1]
            a[i][1] = 0

print(sum([a[i][1] for i in range(n)]))