n, q = map(int, input().split())
s = input()
tds = [input().split() for _ in range(q)]
tds.reverse()

l = 0
r = n - 1

for t, d in tds:
    if s[l] == t and d == "L":
        l += 1
    elif s[r] == t and d == "R":
        r -= 1
    if l > r:
        break
print(l, r)
print(r - l + 1)
