# -*- coding: utf-8 -*-

# n, q = map(int, input().split())
# s = input()
# e = n
# g = [1] * n
#
# m = {}
# for i, c in enumerate(s):
#     if c not in m:
#         m[c] = []
#     m[c].append(i)
#
# for _ in range(q):
#     t, d = input().split()
#
#     if t not in m:
#         continue
#
#     move = -1 if d == "L" else 1
#
#     for j in m[t][::-move]:
#         if g[j] == 0:
#             continue
#         elif (j + move) < 0 or (j + move) >= n:
#             e -= g[j]
#         else:
#             g[(j + move)] += g[j]
#         g[j] = 0
#
# print(e)

n, q = map(int, input().split())
s = input()
tds = [input().split() for _ in range(q)]
tds.reverse()

l = 0
r = n - 1

for t, d in tds:
    if s[l] == t and d == "L":
        l += 1
    if l > 0 and s[l - 1] == t and d == "R":
        l -= 1
    if s[r] == t and d == "R":
        r -= 1
    if r < n - 1 and s[r + 1] == t and d == "L":
        r += 1
    if l > r:
        break

print(r - l - 1)
