import sys
sys.setrecursionlimit(1000000)
#def input():
#    return sys.stdin.readline()[:-1]

'''
n=int(input())
for i in range(n):
    a[i]=int(input())
    a[i],b[i]=map(int,input().split())
a=[int(x) for x in input().split()]
n,m=map(int,input.split())
from operator import itemgetter
a = [(1, "c", 1), (1, "b", 3), (2, "a", 0), (1, "a", 2)]
print(sorted(a))  # 0 番目の要素でソート、先頭の要素が同じなら 1 番目以降の要素も見る
print(sorted(a, key=itemgetter(0)))  # 0 番目の要素だけでソート
print(sorted(a, key=itemgetter(0, 2)))  # 0 番目と 2 番目の要素でソート
print(sorted(a, key=lambda x: x[0] * x[2]))  # 0 番目の要素 * 2 番目の要素でソート
print(sorted(a, reverse=True))  # 降順にソート
a.sort()  # 破壊的にソート、sorted() よりも高速
try: # エラーキャッチ list index out of range
    for i in range():
        k=b[i]
except IndexError as e:
    print(i)
'''

test_data1 = '''\
3 4
ABC
A L
B L
B R
A R
'''

test_data2 = '''\
2 3 0
4 5 6
7 8 9
-1 2 -5
'''

test_data3 = '''\
10 15
SNCZWRCEWB
B R
R R
E R
W R
Z L
S R
Q L
W L
B R
C L
A L
N L
E R
Z L
S L
'''
td_num=1

def GetTestData(index):
    if index==1:
        return test_data1
    if index==2:
        return test_data2
    if index==3:
        return test_data3

if False:
    with open("../test.txt", mode='w') as f:
        f.write(GetTestData(td_num))
    with open("../test.txt") as f:
        # Start Input code ---------------------------------------
        n,q=map(int,f.readline().split())
        s=str(f.readline())
        t=['']*q
        d=['']*q
        for i in range(q):
            t[i],d[i]=map(str,f.readline().split())
        # End Input code ---------------------------------------
else:
    for i in range(1):
        # Start Input code ---------------------------------------
        n,q=map(int,input().split())
        s=str(input())
        t=['']*q
        d=['']*q
        for i in range(q):
            t[i],d[i]=map(str,input().split())
        # End Input code ---------------------------------------

def order(x): # return goal of x-th golem
    l=x
    for i in range(q):
        if s[l]==t[i]:
            l+=1 if d[i]=='R' else -1
            if l>=n or l<0:
                rt = 1 if l>=n else -1
                return rt
    return 0
ans=0

# find leftest golem
lc=0
rc=n-1
lv=order(lc)
rv=order(rc)
while rc-lc>1:
    cc=int((rc+lc)/2)
    cv=order(cc)
    if cv==1:
        rc=cc
        rv=cv
        cc=int((lc+cc)/2)
    else:
        lc=cc
        lv=cv
        cc=int((cc+rc)/2)
r=lc if rv==1 else rc

# find rightest golem
lc=0
rc=n-1
lv=order(lc)
rv=order(rc)
while rc-lc>1:
    cc=int((rc+lc)/2)
    cv=order(cc)
    if cv==-1:
        lc=cc
        lv=cv
        cc=int((cc+rc)/2)
    else:
        rc=cc
        rv=cv
        cc=int((lc+cc)/2)
l=rc if lv==-1 else lc

print(r-l+1)
