n, q = map(int, input().split())
s = input()
spell = [tuple(input().split()) for _ in range(q)]
def sim(i):
    for t, d in spell:
        if s[i] == t:
            if d == 'L':
                if i == 0:
                    return -1
                else:
                    i -= 1
            elif d == 'R':
                if i == n-1:
                    return 1
                else:
                    i += 1
    return 0
dropleft, dropright = 0, 0
if sim(n-1) == -1:
    print(n)
    exit()
if sim(0) == 1:
    print(n)
    exit()
if sim(0):
    l = 0
    r = n-1
    while r - l > 1:
        mid = (l + r)//2
        if sim(mid):
            l = mid
        else:
            r = mid
    dropleft = r
if sim(n-1):
    l = 0
    r = n-1
    while r - l > 1:
        mid = (l + r)//2
        if sim(mid):
            r = mid
        else:
            l = mid
    dropright = n - r
print(n - dropleft - dropright)