# -*- coding: utf-8 -*-
"""
Created on Sat Mar 30 15:26:28 2019

@author: maezawa
"""

n, q = list(map(int, input().split()))
s = input()
qs = []
for i in range(q):
    ti, di = input().split()
    qs.append([ti, di])
    
def isaliveleft(p):
    current = p
    for query in qs:
        if query[0] == s[current]:
            if query[1] == 'L':
                current -= 1
                if current < 0:
                    return False
            else:
                current += 1
                if current >= n:
                    return True
    return True

def isaliveright(p):
    current = p
    for query in qs:
        if query[0] == s[current]:
            if query[1] == 'R':
                current += 1
                if current >= n:
                    return False
            else:
                current -= 1
                if current < 0:
                    return True
    return True

# find left limit
left = 0
right = n-1
if isaliveleft(left):
    ansleft = -1
elif isaliveleft(right) == False:
    ansleft = n
else:
    while True:
        mid = (right + left)//2
        if isaliveleft(mid):
            right = mid
        else:
            left = mid
        if right - left <= 1:
            ansleft = left
            break

# find right limit
left = 0
right = n-1
if isaliveright(right):
    ansright = n
elif isaliveright(left) == False:
    ansright = -1
else:
    while True:
        mid = (right + left)//2
        if isaliveright(mid):
            left = mid
        else:
            right = mid
        if right - left <= 1:
            ansright = right
            break
    
print(ansright - ansleft - 1)