import sys
input = sys.stdin.readline

nq = input()
nq = nq.replace('\n')
s = input() # マス目の情報
s = s.replace('\n')
pprint(nq)
pprint(s)

n = int(nq.split(' ')[0]) # ゴーレムの数
board = [1 for i in range(n)]
q = int(nq.split(' ')[1]) # 試行回数

for i in range(q):
    td = input()
    td = td.replace('\n')
    t = td.split(' ')[0]
    d = td.split(' ')[1]

    j = 0
    k = 0
    for i in range(n):
        if not s[k] == t:
            j += 1
            k += 1
            continue
        if board[j] == 0:
            j += 1
            continue
        if d == 'L':
            a = board[j] 
            board[j] = 0
            p = j - 1
            if p >= 0:
                board[p] = board[p] + a
            else:
                n = n -1
            j += 1
            k += 1
            continue
        if d == 'R':
            a = board[j] 
            board[j] = 0
            p = j + 1
            if p < n:
                board[p] = board[p] + a
            else:
                n = n -1
            j += 1
            k += 1
            continue

print('{}'.format(sum(board)))

