
def resolve():
    def check(pos):
        for t, d in TD:
            if S[pos] != t:
                continue
            if d == "L":
                pos -= 1
            else:
                pos += 1
            # 左に落ちる
            if pos < 0:
                return -1
            # 右に落ちる
            if pos >= N:
                return 1
        return 0

    N, Q = map(int, input().split())
    S = input()
    TD = [list(input().split()) for _ in range(Q)]

    # 左側の境目: 左橋から最も離れた位置
    ok = -1
    ng = N
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if check(mid) == -1:
            ok = mid
        else:
            ng = mid
    left = ok + 1

    # 右側の境目: 右橋から最も離れた位置
    ok = N
    ng = -1
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if check(mid) == 1:
            ok = mid
        else:
            ng = mid
    right = N - ok

    ans = N - (right + left)
    print(ans)


if __name__ == "__main__":
    resolve()
