def main():
    N, Q = map(int, input().split())
    s = input()
    l = []
    for _ in range(Q):
        t, d = input().split()
        l.append((t, d))
    lmax = N
    lmin = 1
    rmax = N
    rmin = 1
    # find most left R
    while rmax != rmin:
        m = t = (rmax + rmin) // 2
        for i in range(Q):
            if s[t-1] == l[i][0]:
                if l[i][1] == 'L':
                    t -= 1
                else:
                    t += 1
            if t == N+1:
                rmax = m
                break
        else:
            rmin = m + 1
    # find most right L
    while lmax != lmin:
        m = t = (lmax + lmin + 1) // 2
        for i in range(Q):
            if s[t-1] == l[i][0]:
                if l[i][1] == 'L':
                    t -= 1
                else:
                    t += 1
            if t == 0:
                lmin = m
                break
        else:
            lmax = m - 1
    if rmax == N:
        print(rmax-lmax)
    else:
        print(rmax-lmax-1)
main()
