#coding:utf-8
import numpy as np
N, Q = map(int,input().split())
S = input()
arr = np.ones(N)
for q in range(Q):
    t, d = input().split()
    mask = np.array([arr[i] if s==t else 0  for i,s in enumerate(S)])
    arr = arr - mask
    if d == "L":
        mask = np.roll(mask, -1)
        mask[-1] = 0
    else:
        mask = np.roll(mask, 1)
        mask[0] = 0
    arr += mask
print (int(arr.sum()))
