N, Q = map(int, input().split())
S = input()
S = 's' + S + 's'
T, D = [], []
dct = {i: 1 for i in range(1, N+1)}
dct[0] = 0
dct[N+1] = 0
for _ in range(Q):
    t, d = input().split()
    T.append(t)
    D.append(d)
for t, d in zip(T, D):
    tmp_dct = {}
    for i, cnt in dct.items():
        if S[i] == t:
            if d == 'L':
                if i-1 in tmp_dct:
                    tmp_dct[i-1] += cnt
                else:
                    tmp_dct[i-1] = cnt
            else:
                if i+1 in tmp_dct:
                    tmp_dct[i+1] += cnt
                else:
                    tmp_dct[i+1] = cnt
        else:
            if i in tmp_dct:
                tmp_dct[i] += cnt
            else:
                tmp_dct[i] = cnt
    dct = tmp_dct
print(N - dct[0] - dct[N+1])