n,q=map(int, input().split())
s=input()
queri=[]
for i in range(q):
    t,d=input().split()
    queri.append((t,d))
for t,d in queri[::-1]:
    if not s:break
    if d=='R' and t==s[-1]:s=s[:-1]
    if d=='L' and t==s[0]:s=s[1:]
print(len(s))