N, Q = map(int, input().split())
s = str(input())
coms = [list(map(str, input().split())) for _ in range(Q)]


def ok_lower(A, index, coms):
    # シミュレーションを行う
    for com in coms:
        if com[0] == A[index]:
            if com[1] == 'R':
                index += 1
            elif com[1] == 'L':
                index -= 1
            if index == len(A):
                return True
            elif index == -1:
                return False
    return False


def ok_upper(A, index, coms):
    # シミュレーションを行う
    for com in coms:
        if com[0] == A[index]:
            if com[1] == 'R':
                index += 1
            elif com[1] == 'L':
                index -= 1
            if index == len(A):
                return False
            elif index == -1:
                return True
    return False


def lower_bound(A, coms):
    ng = -1
    ok = len(A)

    while(abs(ok-ng) > 1):
        mid = (ok + ng) // 2

        if ok_lower(A, mid, coms):
            ok = mid
        else:
            ng = mid
    return ok


def upper_bound(A, coms):
    ng = len(A)
    ok = -1

    while(abs(ok-ng) > 1):
        mid = (ok + ng) // 2

        if ok_upper(A, mid, coms):
            ok = mid
        else:
            ng = mid
    return ok


lower = lower_bound(s, coms)
upper = upper_bound(s, coms)
print(max(0, lower-upper-1))
