
def isDead(pos):
    nPos = pos
    for magic in td:
        if S[nPos] == magic[0]:
            if magic[1] == 'L':
                nPos -= 1
            else:
                nPos += 1
                pass
            pass

        if (nPos < 0) or (nPos > N-1):
            return True
            pass
        pass # end for
    return False

N, Q = map(int, input().split())
S = input()
td = [input().split() for _ in range(Q)]


left = 0
right = N-1
while(left <= N-1):
    if(isDead(left) == False):
        break
    left += 1
    pass

while(right >= left):
    if(isDead(right) == False):
        break
    right -= 1
    pass
#left   #左側から死んだ数
#N-1 - right  #右側から死んだ数

alive = right - left + 1

print(alive)
