n, q = map(int, input().strip().split(' '))
s = input()
basyo = [[str(c),1] for c in s]
for i in range(q):
    t, d = map(str, input().strip().split(' '))
    if d == "L":
        if basyo[0][0] == t:
            basyo[0][1] = 0
        for j in range(1, n):
            if basyo[j][0] == t:
                basyo[j-1][1] = basyo[j-1][1]+basyo[j][1]
                basyo[j][1] = 0
            else:
                pass
    else:
        if basyo[n-1][0] == t:
            basyo[n-1][1] = 0
        for j in reversed(range(0, n-1)):
            if basyo[j][0] == t:
                basyo[j+1][1] = basyo[j+1][1]+basyo[j][1]
                basyo[j][1] = 0
            else:
                pass
kazu = 0
for i in range(n):
    kazu = kazu + basyo[i][1]
print(kazu)