#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    if a == b and b == c:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    s = S()
    if s.count("R") > s.count("B"):
        print("Yes")
    else:
        print("No")
    return

#C
def C():
    n, q = LI()
    s = S()
    td = LSR(q)
    ans = n
    for num in range(n):
        for t, d in td:
            if s[num] == t[0]:
                if d == ["L"]:
                    num -= 1
                else:
                    num += 1
            if num == -1 or num == n:
                ans -= 1
                break
    print(ans)
    return

#D
def D():
    n, xb = LI()
    s = LI()
    a = list(itertools.permutations(range(n), n))
    ans = 0
    ss = min(s)
    for a_ in a:
        x = xb
        for aa in a_:
            #print(x,s[aa],x%s[aa],end=" : ",)
            x = x % s[aa]
            if x < ss:
                break
            elif x == ss:
                x = 0
                break
        #print(a_, x)
        ans += x % mod
    print(ans % mod)

    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()
