n, q = map(int,input().split())
s = input()
T = [list(input().split()) for i in range(q)]

ans = 0
a = 0
a0 = 0
for i in range(q-1, -1, -1):
    if a < n and T[i] == [s[a], "L"]:
        a += 1
    elif a > 0 and T[i] == [s[a-1], "R"]:
        a -= 1
    a0 = max(a0, a)

ans += a0
# print("a0",a0)

a = 0
a0 = 0
s = s[::-1]
for i in range(q-1, -1, -1):
    if a < n and T[i] == [s[a], "R"]:
        a += 1
    elif a > 0 and T[i] == [s[a-1], "L"]:
        a -= 1
    a0 = max(a0, a)

ans += a0

print(n-ans)