#! /usr/bin/env python
# -*- coding: utf-8 -*-
sN = []
sQ = []
Q = 0
N = 0
def goR(pos):
    for i in range(Q):
        if sN[pos] == sQ[i]['t']:
            if sQ[i]['d'] == 'R':
                pos = pos + 1
            else:
                pos = pos - 1

            if(pos < 0):
                return False
            if(pos > N -1):
                return True

    if(pos > N - 1):
        return True
    else:
        return False

def getR():
    l = 0
    r = N - 1
    res = N
    while(l <= r):
        mid = (l+r+1)//2
        if(goR(mid)):
            res = mid
            if(r == l):
                break
            r = mid - 1
        else:
            l = mid + 1
    return N - res

def goL(pos):
    for i in range(Q):
        if sN[pos] == sQ[i]['t']:
            if sQ[i]['d'] == 'L':
                pos = pos - 1
            else:
                pos = pos + 1

            if(pos > N -1):
                return False
            if(pos < 0):
                return True

    if(pos < 0):
        return True
    else:
        return False

def getL():
    l = 0
    r = N - 1
    res = -1
    while(l <= r):
        mid = (l+r+1)//2
        if(goL(mid)):
            res = mid
            l = mid + 1
            if(r == l):
                break
        else:
            r = mid - 1
    return res + 1

if __name__ == '__main__':
    N, Q = map(int, input().split()) # N, Q for number

    sN = list(input())  # squares

    for i in range(0, Q):
        t, d = input().split()
        sQ.append({'t': t, 'd': d})

    print(N-getL()-getR())

