def main():
    def solve(mid,g):
        for t,d in zip(x,y):
            if s[mid]==t:
                mid-=(d<'R')or-1
                if mid==g:
                    return 1
        return 0
    n,q,s,*z=open(0).read().split()
    x,y=z[::2],z[1::2]
    n,q=int(n),int(q)
    s=' %s '%s
    ok=0
    ng=n+1
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if solve(mid,0):
            ok=mid
        else:
            ng=mid
    a=ok
    ok=n+1
    ng=0
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if solve(mid,n+1):
            ok=mid
        else:
            ng=mid
    print(max(0,ok-a-1))
if __name__=='__main__':
    main()