# -*- coding: utf-8 -*-

import numpy as np

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

    keys = set(s)
    dic = {}
    for i, k in enumerate(s):
        if k not in dic:
            dic[k] = [i]
        else:
            dic[k].append(i)
    
    cells = np.array([1] * N, dtype=int)
    for _ in range(Q):
        t, d = input().split(' ')
        if t not in keys:
            continue

        diffs = np.zeros(cells.shape, dtype=int)
        d = -1 if d == 'L' else 1
        for i in dic[t]:
            diffs[i] += -cells[i]
            if 0 <= i + d < N:
                diffs[i + d] += cells[i]
        
        cells = cells + diffs

    print(np.sum(cells))
