# Original solution
#!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([int(x)-1 for x in 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
    anslist = [-1 for i in range(n)]
    for num in range(n):
        for tdnum, td_ in enumerate(td):
            t = td_[0][0]
            d = td_[1][0]
            numb = num
            if anslist[num] >= tdnum:
                ans -= 1
                break
            if s[num] == t:
                if d == "L":
                    num -= 1
                else:
                    num += 1
            if num == -1 or num == n:
                anslist[numb] = tdnum
                ans -= 1
                break
    print(ans)
    return

#D
def D():
    n, xb = LI()
    s = LI()
    a = list(itertools.permutations(list(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()


# Optimized solution
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list([int(x)-1 for x in input().split()])
def II(): return int(eval(input()))
def IF(): return float(eval(input()))
def LS(): return input().rstrip().split()
def S(): return list(input().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 = 1e10



#solve
def solve():
    def f0(x):
        for td_ in td:
            if td_[0] == s[x]:
                if td_[1] == "L":
                    x -= 1
                else:
                    x += 1
            if x < 0:
                return True
            if x >= n:
                return False
        return False
    def f1(x):
        for td_ in td:
            if td_[0] == s[x]:
                if td_[1] == "L":
                    x -= 1
                else:
                    x += 1
            if x >= n:
                return True
            if x < 0:
                return False
        return False

    n, q = LI()
    s = S()
    td = LSR(q)
    ok = -1
    ng = n
    ans = n
    while ng - ok > 1:
        mid = (ng - ok) // 2 + ok
        if f0(mid):
            ok = mid
        else:
            ng = mid
    ans -= ok  + 1
    ok = n
    ng = -1
    while ok - ng > 1:
        mid = (ok - ng) // 2 + ng
        if f1(mid):
            ok = mid
        else:
            ng = mid
    ans -= n - ok
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()