def go():
    n,q=map(int,input().split())
    mas=[1 for i in range(n)]
    s=list(input())
    td=[list(map(str,input().split()))for i in range(q)]
    for t,d in td:
        indexall=[i for i, x in enumerate(s) if x==t]
        for i in indexall:
            if mas[i]>0:
                memo=mas[i]
                mas[i]=0
                if d=='L':
                    if i-1>=0:
                        mas[i-1]+=memo
                else:
                    if i+1<=n-1:
                        mas[i+1]+=memo

    return sum(mas)

print(go())