n,q = map(int,input().split())
s = input()
left = s[0]
right = s[-1]
r_count = 0
l_count = 0
counter = 0

for i in range(q):
    t,d = input().split()
    if (t == left and d == "L") or (t == right and d == "R"):
        counter += abs(r_count-l_count) + 1
        r_count = 0
        l_count = 0
    elif d == "R":
        r_count += 1
    elif d == "L":
        l_count += 1
        
print(n - counter)