N, Q = map(int, input().split())
s = input()
td = [input().split() for _ in range(Q)]
def C(x):
    if x == -1:
        return True
    if x == N:
        return False
    for t, d in td:
        if s[x] != t:
            continue
        if d == 'L':
            if x == 0:
                return True
            x-=1
        else:
            if x == N-1:
                return False
            x+=1
    return False
ans = N
ok = -1
ng = N
while ng-ok>1:
    mid = (ok+ng)//2
    if C(mid):
        ok = mid
    else:
        ng = mid
ans-=ok+1
s = list(reversed(s))
td = [[t, 'L'] if d == 'R' else [t, 'R'] for t, d in td]
ok = -1
ng = N
while ng-ok>1:
    mid = (ok+ng)//2
    if C(mid):
        ok = mid
    else:
        ng = mid    
ans-=ok+1
print(ans)