import sys


def simulate(i, check_out_bound):
    for t, d in commands:
        if t == s[i]:
            if d == 'L':
                i -= 1
            else:
                i += 1
        if check_out_bound(i):
            return False
    return True


def check(is_left, check_out_bound):
    l, r = 0, n - 1
    while l < r:
        m = (l + r) // 2
        if simulate(m, check_out_bound):
            if is_left:
                r = m
            else:
                l = m
        else:
            if is_left:
                l = m + 1
            else:
                r = m - 1
        # print(is_left, l, r)
    return l


n, q = map(int, input().split())
s = input()
commands = [line.rstrip().split() for line in sys.stdin]

check_out_bound_l = lambda i: i < 0
check_out_bound_r = lambda i: i >= n
if simulate(0, check_out_bound_l):
    bl = 0
else:
    bl = check(True, check_out_bound_l)
if simulate(n - 1, check_out_bound_r):
    br = n - 1
else:
    br = check(False, check_out_bound_r)
print(br - bl + 1)
