N, Q = map(int, input().split())
s = input()

# make dict structure
STW = [[s[i], 1] for i in range(N)]

# print(STW)
for j in range(Q):
    t, d = map(str, input().split())
    if d == 'L':
        for i in range(N):
            if STW[i][0] == t:
                if i == 0:
                    STW[0][1] = 0
                else:
                    STW[i - 1][1] += STW[i][1]
                    STW[i][1] = 0
    else:
        for i in range(N):
            if STW[N-1-i][0] == t:
                if i == 0:
                    STW[N-1][1] = 0
                else:
                    STW[N-1-i+1][1] += STW[N-1-i][1]
                    STW[N-1-i][1] = 0

c = 0
for i in range(N):
    c += STW[i][1]

print(c)
