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())
        if b == "R":
            b = 1
        else:
            b = -1
        move.append((a,b))
        
    def drop_out(pos,edge):
        col = s[pos]
        for c,d in move:
            if c == col:
                pos += d
                if pos == edge:
                    return True
                col = s[pos]
        return False
    
    l,r = 0,N+1
    while r-l>1:
        mid = (l+r)//2
        if drop_out(mid,0):
            l = mid
        else:
            r = mid
    left = l
    
    l,r = 0,N+1
    while r-l>1:
        mid = (l+r)//2
        if drop_out(mid,N+1):
            r = mid
        else:
            l = mid
    right = r

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