N, Q = map(int, input().split())
string = input()
masu = [1]*N
for i in range(Q):
    t, d = input().split()
    for j, s in enumerate(string):
        if s == t:
            if d == "L":
                if j == 0:
                    masu[j] = 0
                else:
                    masu[j - 1] += masu[j]
                    masu[j] = 0
            if d == "R":
                if j == N-1:
                    masu[j] = 0
                else:
                    masu[j + 1] += masu[j]
                    masu[j] = 0
print(sum(masu))
