
def isDead(pos):
    nPos = pos
    for magic in td:
        if (nPos < 0):
            return -1
        elif (nPos > N-1):
            return 1
        
        if S[nPos] == magic[0]:
            if magic[1] == 'L':
                nPos -= 1
            else:
                nPos += 1

        pass # end for
    return 0

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

# 二分法で左側の解を求める
lAns = -1
if isDead(0) > -1:
    # 解なし
    lAns = -1
    pass
else:
    tmpMin = -1
    tmpMax = N
    tmp = N // 2
    while( (tmpMax - tmpMin) > 1):
        tmp = (tmpMin + tmpMax) // 2
        if(isDead(tmp) == -1):
            tmpMin = tmp
        else:
            tmpMax = tmp
        pass

    lAns = tmpMin
    # 左側死んだ数 = lAns + 1



# 二分法で右側の解を求める
rAns = N-1
if isDead(N-1) < 1:
    # 解なし
    rAns = N-1
    pass
else:
    tmpMin = -1
    tmpMax = N
    tmp = N // 2
    while( (tmpMax - tmpMin) > 1):
        tmp = (tmpMin + tmpMax) // 2
        if(isDead(tmp) == 1):
            tmpMax = tmp
        else:
            tmpMin = tmp
        pass

    rAns = tmpMin
    # 右側死んだ数 = N - (rAns+1)


# 左側死んだ数 = lAns + 1
# 右側死んだ数 = N - (rAns+1)
# 生きてる数 = rAns -lAns

alive = rAns - lAns

print(alive)
