#!/usr/bin/env python3
# -*- coding: utf-8-*-
import numpy as np
if __name__ == '__main__':
    N, Q = map(int, input().split(" "))
    s = input()
    dic = {}
    for i in range(N):
        if s[i] in dic:
            dic[s[i]].append(i)
        else:
            dic[s[i]] = [i]
    sum = 0
    pa = np.full((N), 1)
    a = pa.copy()
    for _ in range(Q):
        t, d = input().split(" ")
        if t in dic:
            for i in dic[t]:
                if d == "L":
                    if i == 0:
                        sum += pa[i]
                    else:
                        a[i-1] += pa[i]
                    a[i] = 0
                else:
                    if i == N-1:
                        sum += pa[i]
                    else:
                        a[i+1] += pa[i]
                    a[i] = 0
        pa = a.copy()
    print(N-sum)
