N, Q = map(int, input().split())
s = input()
query = []
for i in range(Q):
    t, d = input().split()
    query.append([t, d])


def onequery(number):
    bool = True
    for i in range(Q):
        if s[number-1] == query[i][0]:
            if query[i][1] == "R":
                number += 1
            else:
                number -= 1
        if number <= 0 or number >= N+1:
            bool = False
            return bool
    return bool


left = 0
right = N+1
while right - left > 1:
    mid = left + (right - left) // 2
    if onequery(mid):
        right = mid
    else:
        left = mid
leftans = right


left = 0
right = N + 1
while right - left > 1:
    mid = left + (right - left) // 2
    if not onequery(mid):
        right = mid
    else:
        left = mid

rightans = left
print(rightans - leftans + 1)
