def main():
    from collections import namedtuple

    Q = namedtuple('Q', 'char drc')

    def binary_search(ng, ok):
        def is_ok(mid):
            """落下するならTrue"""
            for q_ in qs:
                if s[mid] == q_.char:
                    mid += q_.drc
                    if mid < 0 or mid >= n:
                        return True
            return False

        while abs(ng - ok) > 1:
            mid = (ng + ok) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok

    n, q = map(int, input().split())
    s = input()

    qs = []
    for _ in range(q):
        t, d = input().split()
        d = -1 if (d == 'L') else 1
        qs.append(Q(char=t, drc=d))
        # char:指定マス文字,英大文字
        # drc:方向,L=-1,R=1

    mid = n // 2
    left = binary_search(ng=mid + 1, ok=-1)  # okを返すので、最大mid
    right = binary_search(ng=mid, ok=n)  # okを返すので、最小mid+1
    # ok=落下する境目（落下側）
    # oolxxxroo -> r-1-l=6-1-2=3=xの個数
    # 012345678

    print(right - 1 - left)


if __name__ == '__main__':
    main()
