import sys
#input = sys.stdin.buffer.readline

def main():
    N,M = map(int,input().split())
    s = "_" + input() + "_"
    move = []
    for _ in range(M):
        a,b = map(str,input().split())
        move.append((a,b))
        
    def drop_out(pos,lr):
        now = s[pos]
        if lr == "r":
            for i in range(M):
                if move[i][0] == now:
                    if move[i][1] == "R":
                        pos += 1
                        if pos == N+1:
                            return False
                        now = s[pos]
        else:
            for i in range(M):
                if move[i][0] == s[pos]:
                    if move[i][1] == "L":
                        pos -= 1
                        if pos == 0:
                            return False
                        now = s[pos]
        return True
    
    l,r = 0,N+1
    while r-l>1:
        mid = (l+r)//2
        if drop_out(mid,"r"):
            l = mid
        else:
            r = mid
    right = r
    
    l,r = 0,N+1
    while r-l>1:
        mid = (l+r)//2
        if drop_out(mid,"l"):
            r = mid
        else:
            l = mid
    left = l

    print(max(right-left-1,0))
    
if __name__ == "__main__":
    main()
