def countr(s):
    c = 0
    for i in range(0,len(s)):
        if s[i] == "R":
            c = c + 1
    return c

def countl(s):
    c = 0
    for i in range(0,len(s)):
        if s[i] == "L":
            c = c + 1
    return c

def main():
    N, Q = input().split()
    N = int(N)
    Q = int(Q)
    G = [1] * N
    S = input()
    ts = ""
    ds = ""
    for j in range(0,Q):
        t, d = input().split()
        ts = ts + t
        ds = ds + d
    l = countl(ds)
    r = countr(ds)
    #print(ds)
    #print(l)
    #print(r)
        
    for j in range(0,Q):
        t = ts[j]
        d = ds[j]
        
        if d == "L":
            # for i in range(0,N):
            for i in range(0,N):
                if l < i and i < N-r:
                    continue
                if S[i] == t and G[i] > 0:
                    if i == 0:
                        G[i] = 0
                    else:
                        G[i-1] = G[i-1] + G[i]
                        G[i] = 0
            l = l - 1

        else: # "R"
            # for i in range(N-1,-1,-1):
            for i in range(N-1,-1,-1):
                if l < i and i < N-r:
                    continue
                if S[i] == t and G[i] > 0:
                    if i == N-1:
                        G[i] = 0
                    else:
                        G[i+1] = G[i+1] + G[i]
                        G[i] = 0
            r = r -1
        #print(G)
    print(sum(G))

if __name__ == '__main__':
    main()
