<?php

fscanf(STDIN, "%d %d", $n, $q);
fscanf(STDIN, "%s", $s);
$inputs = [];
for ($i = 0; $q > $i; $i++) {
    fscanf(STDIN,"%s %s", $tmp1, $tmp2);
    $inputs[] = [$tmp1, $tmp2];
}

//var_dump([$n, $q, $s, $inputs]);

#simple
$rooms = [];
for ($i = 0; strlen($s) > $i; $i++) {
    $rooms[$i] = [$s[$i], 1]; #部屋の初期化
}
$roommax = count($rooms) - 1;
#var_dump([$s, $rooms, $roommax]);
#exit;
foreach ($inputs as $input) {
    list ($roomid, $magic) = $input;
    #var_dump([$roomid, $magic]);
    #絶対TLE
    foreach ($rooms as $seq => $room) {
        //var_dump([$roomid, $magic, $seq, $room]);
        if ($room[0] == $roomid) {
            if ($magic == 'R') {
                $next = $seq + 1;
                if ($seq == $roommax) {
                    $rooms[$seq][1] = 0;
                } else {
                    $rooms[$next][1] += $rooms[$seq][1];
                    $rooms[$seq][1] = 0;
                }
            } else {
                $prev = $seq - 1;
                if ($seq == 0) {
                    $rooms[$seq][1] = 0;
                } else {
                    $rooms[$prev][1] += $rooms[$seq][1];
                    $rooms[$seq][1] = 0;
                }

            }
        }
    }
}
$count = 0;
foreach ($rooms as $room) {
    //var_dump($room);
    $count += $room[1];
}
echo $count;
#var_dump($rooms);

