tt = []
dd = []
ss = []
Q = 0
N = 0

def pos(p):
    target = ss[p]
    for i in range(Q):
        if tt[i] == target:
            if dd[i] == 'L':
                p -= 1
                if (p < 0):
                    return 'L'
                target = ss[p]
            else:
                p += 1
                if (N <= p):
                    return 'R'
                target = ss[p]
    return 'I'

def ans_l(prev_l, prev_r):
    diff = prev_r - prev_l
    if diff == 1:
        if pos(prev_l) == 'L':
            return prev_r
        else:
            return prev_l
    i = int(prev_l + diff / 2)
    if pos(i) == 'L':
        return ans_l(i, prev_r)
    else:
        return ans_l(prev_l, i)

def ans_r(prev_l, prev_r):
    # print(prev_l)
    # print(prev_r)
    diff = prev_r - prev_l
    if diff == 1:
        if pos(prev_r) == 'R':
            return prev_l
        else:
            return prev_r
    i = int(prev_l + diff / 2)
    if pos(i) == 'R':
        return ans_r(prev_l, i)
    else:
        return ans_r(i, prev_r)

N,Q = map(int, input().split())
s = input()

ss = list(s)
nn = []

i = 0
for c in ss:
    i += 1
    nn.append(1)

for i in range(Q):
    t, d = map(str, input().split())
    tt.append(t)
    dd.append(d)

l = ans_l(0, N - 1)
r = ans_r(0, N - 1)
#print(l)
#print(r)
print(sum(nn[l:r+1]))
