# calc order -> O(QlogN)
N, Q = map(int, input().split())

s = input()
s = " "+s+" "
moves = [{}] * Q
for i in range(Q):
    t,d = input().split()
    moves[i] = {"name":t, "direction":d}
"""

N,Q = 8,3
s = " AABCBDBA "
moves= [{'direction': 'L', 'name': 'A'}, {'direction': 'R', 'name': 'B'}, {'direction': 'R', 'name': 'A'}]
"""
start=1
end=N
mid = (start+end)//2

def vanish_check(i):
    '''
    reaches s[0] first => return 1
    reaches s[N+1] first => return 2
    does not vanish => return 3
    '''
    pos = i
    for move in moves:
        if pos==0:
            return 1
        elif pos==(N+1):
            return 2
        else:
            if s[pos] == move["name"]:
                if move["direction"]== "L":
                    pos -= 1
                else:
                    pos += 1
    if pos==0:
        return 1
    elif pos==N+1:
        return 2
    else:
        return 3

def find_most_right_returns_1(start,mid,end):
    if start==mid or mid==end:
        if vanish_check(mid)==1:
            return mid
        else:
            return mid-1
    if vanish_check(mid) == 1:
        start = mid+1
        mid = (start + end)//2
        return find_most_right_returns_1(start,mid,end)
    else:
        end = mid-1
        mid = (start + end)//2
        return find_most_right_returns_1(start,mid,end)

def find_most_left_returns_2(start,mid,end):
    if start==mid or mid==end:
        if vanish_check(mid)==2:
            return N+1-mid
        else:
            return N-mid
    if vanish_check(mid) ==2:
        end = mid-1
        mid = (start+end)//2
        return find_most_left_returns_2(start,mid,end)
    else:
        start = mid+1
        mid = (start + end)//2
        return find_most_left_returns_2(start,mid,end)

print(N-(find_most_right_returns_1(start,mid,end) + find_most_left_returns_2(start,mid,end)))