function Main(input) {

  var input = input.split("\n");
  var n = input[0].split(" ")[0];
  var q = input[0].split(" ")[1];
  var arys = input[1].split("");
  var sn = new Array();

  arys.forEach(function(e, i) {
    sn[i] = [e, 1];
  });

  var flag = 0;
  for(var i=2;i< input.length;i++){
    var t = input[i].split(" ")[0];
    var d = input[i].split(" ")[1];

    if(d == "R") {
      sn.reverse();
      flag = 1;
    }
    sn.forEach(function(e, i) {
      if(t == sn[i][0]) {
        if(i === 0) {
          sn[i][1] = 0;
        } else {
          var count = sn[i][1] + sn[i-1][1];
          sn[i][1] = 0;
          sn[i-1][1] = count;
        }
      }
    });

    if(flag === 1) {
      sn.reverse();
      flag = 0;
    }
  }
  var result = 0;
  sn.forEach(function(e, i) {
    result = result + sn[i][1];
  });
  console.log(result);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));