def is_vanished_from_left(s, i, spells):
    for spell in spells:
        if s[i] == spell[0]:
            if spell[1] == 'L':
                i -= 1
            else:
                i += 1
        if i < 0:
            return True
        if len(s) <= i:
            return False
    return False


def is_vanished_from_right(s, i, spells):
    for spell in spells:
        if s[i] == spell[0]:
            if spell[1] == 'L':
                i -= 1
            else:
                i += 1
        if len(s) <= i:
            return True
        if i < 0:
            return False
    return False


def main():
    N, Q = list(map(int, input().split()))
    s = list(input())

    spells = []
    for i in range(Q):
        spell = input().split()
        spells.append(spell)

    if len(s) == 0:
        print(0)
        exit(0)
    if len(s) == 1:
        for spell in spells:
            if s[0] == spell[0]:
                print(0)
                exit(0)

    # Left
    pos = len(s) - 1
    while True:
        if pos < 1 or len(s) <= pos:
            pos = -1
            break
        prev = pos
        ret1 = is_vanished_from_left(s, pos, spells)
        ret2 = is_vanished_from_left(s, pos - 1, spells)
        # print("left: {}: {}, {}: {}".format(pos, ret1, pos - 1, ret2))
        if ret1 is ret2 is False:
            pos = pos // 2
            if prev == pos:
                pos = -1
                break
            continue
        if ret1 is ret2 is True:
            pos += pos // 2 + 1
            if prev == pos:
                pos = -1
                break
            continue
        if ret1 is not ret2:
            break
    left = pos

    pos = 0
    while True:
        if pos < 0 or len(s) - 1 <= pos:
            pos = -1
            break
        prev = pos
        ret1 = is_vanished_from_right(s, pos, spells)
        ret2 = is_vanished_from_right(s, pos + 1, spells)
        # print("right: {}: {}, {}: {}".format(pos, ret1, pos + 1, ret2))
        if ret1 is ret2 is False:
            pos = (len(s) + pos) // 2
            if prev == pos:
                pos = -1
                break
            continue
        if ret1 is ret2 is True:
            pos = pos // 2
            if prev == pos:
                pos = -1
                break
            continue
        if ret1 is not ret2:
            break
    right = pos

    output = len(s)
    if right != -1:
        output -= len(s) - right - 1
    if left != -1:
        output -= left
    print(output)


if __name__ == '__main__':
    main()
