import sys


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


def check(l, r, fall_l, fall_r):
    # print('called', l, r)
    # sl, sr = l, r
    while l < r:
        m = (l + r) // 2
        res = simulate(m, fall_l, fall_r)
        if res == -1:
            l = m + 1
            fall_l = m
        elif res == 1:
            r = m - 1
            fall_r = m
        else:
            l, _ = check(l, m, fall_l, fall_r)
            _, r = check(m + 1, r, fall_l, fall_r)
            # print(f'return1({sl} {sr}) {l} {r}')
            return l, r
    # print(f'return2({sl} {sr}) {l} {r}')
    return l, r


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

l, r = check(0, n - 1, -1, n)
print(r - l + 1)
