<?php

fscanf(STDIN, '%d %d', $n, $q);
fscanf(STDIN, '%s', $s);

$a = str_split($s);

foreach ($a as $k => $v) {
    $a[$k] = [
        'c' => 1,
        's' => $v
    ];
}

for ($i = 1; $i <= $q; $i++) {
    fscanf(STDIN, '%s %s', $t, $d);

    foreach ($a as $k => $v) {
        if ($v['s'] === $t) {
            if ($d === 'L' && 0 <= $k - 1) {
                $a[$k-1]['c'] += $a[$k]['c'];
            }

            if ($d === 'R' && $k + 1 <= $n - 1) {
                $a[$k+1]['c'] += $a[$k]['c'];
            }

            $a[$k]['c'] = 0;
        }
    }

}

$sum = 0;
foreach ($a as $v) {
    $sum += $v['c'];
}

echo $sum . PHP_EOL;
