N, Q = list(map(int, input().split()))
S = input()
G = [[0] for i in range(N)]

for _ in range(Q):
    t, d = input().split()
    for i, s in enumerate(S):
        if (s == t):
            if (d == 'L'):
                if (i == 0):
                    G[0] = []
                else:
                    G[i-1].extend(G[i])
                    G[i] = []
            elif (d == 'R'):
                if (i == N-1):
                    G[N-1] = []
                else:
                    G[i+1].extend(G[i])
                    G[i] = []
ans = sum([len(g) for g in G])
print(ans)
