n,q = map(int,input().split())
s = input()
position = {}
l = 1
for c in s:
    position[l] = 1
    l = l + 1

for l in range(q):
    T,_,D = input()
    l = 1
    new = position
    for c in s:
        if c == T:
            if D == "L":
                new[l] = new[l] - position[l]
                if not l == 1:
                    new[l-1] = new[l-1] + position[l]
            elif D == "R":
                new[l] = new[l] - position[l]
                if not l == n:
                    new[l+1] = new[l+1] + position[l]

ans = 0
for k,v in position.items():
    ans = ans + v
print(ans)