n, q = map(int, input().split())
s = input()
lr = {}
g = []

def move(x):
    return [-1, 1][x=='R']
    
for i in range(n):
    g.append(['G'])

for i in s:
    if i not in lr:
        lr[i] = []
        
for i in range(n):
    lr[s[i]].append(i)

for i in range(q):
    a, b = input().split()
    if a in s:
        for k in lr[a]:
            if k+move(b)<0 or n-1<k+move(b):
                for f in range(len(g[k])):
                    g[k].pop()
            else:
                for f in range(len(g[k])):
                    g[k+move(b)].append(g[k].pop())

count = 0
for v in g:
    count+=v.count('G')
print(count)