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

ss = list(s)

nn = []  # ゴーレムの数
for i in range(N):
    nn.append(1)

for i in range(Q):
    t,d = map(str, input().split())
    k = 0
    for c in ss:
        if c == t and d == 'L':
            if 0 < k:
                nn[k - 1] = nn[k - 1] + nn[k]
            nn[k] = 0
        if c == t and d == 'R':
            if k < N - 1:
                nn[k + 1] = nn[k + 1] + nn[k]
            nn[k] = 0
        k += 1

remain = 0
for i in range(N):
    remain = remain + nn[i]
print(remain)
