<?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);

    $offset = -1;
    do {
        $offset += 1;
        $offset = strpos($s, $t, $offset);
        
        if ($offset !== false) {

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

        }
    } while($offset !== false);
}

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

echo $sum . PHP_EOL;
