#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include<random>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

__int128 EuclidMod(__int128 v, __int128 m){
  if(0 <= v && v < m){
    return v;
  }else if(-m <= v && v < 0){
    return v + m;
  }else{
    __int128 result = v % m;
    if(result < 0){
      result += m;
    }
    return result;
  }
}

__int128 ModInv(__int128 a, __int128 m){
  __int128 b = m, u = 1, v = 0;
  while(b){
    __int128 t = a / b;
    a -= t * b;
    std::swap(a, b);
    u -= t * v;
    std::swap(u, v);
  }
  EuclidMod(u, m);
  return u;
}

// return base^exponent (MOD. mod).
__int128 RepeatedPowMod(__int128 base, __int128 exponent, __int128 mod) {
  if (exponent == 0)
    return 1;
  else if (exponent % 2 == 0) {
    __int128 root = RepeatedPowMod(base, exponent / 2, mod);
    return (root * root) % mod;
  } else {
    return (base * RepeatedPowMod(base, exponent - 1, mod)) % mod;
  }
}

template<__int128 mod>
class ModInt{
  __int128 value_;

public:
  explicit ModInt(const __int128 x = 0): value_(x % mod){
  };

  ModInt& operator=(const ModInt& another){
    value_=another.value_;
    return *this;
  }

  ModInt& operator^=(const ModInt& another){
    value_=RepeatedPowMod(value_,another.value_,mod);
    return *this;
  }

  ModInt& operator+=(const ModInt& another){
    value_ += another.value_;
    value_ = EuclidMod(value_, mod);
    return *this;
  }

  ModInt& operator-=(const ModInt& another){
    value_ -= another.value_;
    value_ = EuclidMod(value_, mod);
    return *this;
  }

  ModInt& operator*=(const ModInt& another){
    value_ *= another.value_;
    value_ = EuclidMod(value_, mod);
    return *this;
  }

  ModInt& operator/=(const ModInt& another){
    value_ = value_ * ModInv(another.value_, mod);
    value_ = EuclidMod(value_, mod);
    return *this;
  }

  ModInt& operator++(){
    value_ += ModInt(1);
    return *this;
  }

  ModInt operator++(int){
    ModInt tmp = *this;
    ++tmp;
    return tmp;
  }

  ModInt& operator--(){
    value_-=ModInt(1);
    return *this;
  }

  ModInt operator--(int){
    ModInt tmp=*this;
    --tmp;
    return tmp;
  }



  __int128 GetValue() const{
    return value_;
  }

};

template<__int128 mod>
ModInt<mod>
operator+(const ModInt<mod>& left, const ModInt<mod>& right){
  return ModInt<mod>(left) += right;
}

template<__int128 mod>
ModInt<mod>
operator-(const ModInt<mod>& left, const ModInt<mod>& right){
  return ModInt<mod>(left) -= right;
}

template<__int128 mod>
ModInt<mod>
operator/(const ModInt<mod>& left, const ModInt<mod>& right){
  return ModInt<mod>(left) /= right;
}

template<__int128 mod>
ModInt<mod>
operator*(const ModInt<mod>& left, const ModInt<mod>& right){
  return ModInt<mod>(left) *= right;
}

template<__int128 mod>
ModInt<mod>
operator^(const ModInt<mod>& left, const ModInt<mod>& right){
  return ModInt<mod>(left) ^= right;
}

template<__int128 mod>
std::ostream& operator<<(std::ostream& stream, const ModInt<mod>& mod_int){
  stream << mod_int.GetValue();
  return stream;
}




class RandomIntNumber {
  std::mt19937_64 mt_maker_;
  std::uniform_int_distribution<int64_t> range_maker_;

public:
  RandomIntNumber(int64_t min, int64_t max) {
    std::random_device seed_maker;
    mt_maker_.seed(seed_maker());
    // range_maker_.min = min;
    // range_maker_.max = max;
    std::uniform_int_distribution<int64_t>::param_type param(min, max);
    range_maker_.param(param);
  }
  int64_t Make(void) {
    return range_maker_(mt_maker_);
  }
  int64_t operator()(void) {
    return Make();
  }
};

class RollingHash{
  static const __int128 MOD_=1000000000000000003;
  std::vector<ModInt<MOD_>> hash_;
  std::string str_;
  RandomIntNumber random_int_number_;
  __int128 base_;

public:
  RollingHash(const std::string& str):random_int_number_(2,MOD_-2),str_(str){
    base_=random_int_number_.Make();
    for(int i=0;i<str.size();i++){
      if(i==0){
        hash_.push_back(ModInt<MOD_>(str[0]));
      }else{
        ModInt<MOD_> result(hash_[i-1]);
        result*=ModInt<MOD_>(base_);
        result+=ModInt<MOD_>(str[i]);
        hash_.push_back(result);
      }
    }
  }
  RollingHash(const std::string& str,__int128 base):random_int_number_(2,MOD_-2),str_(str),base_(base){
    for(int i=0;i<str.size();i++){
      if(i==0){
        hash_.push_back(ModInt<MOD_>(str[0]));
      }else{
        ModInt<MOD_> result(hash_[i-1]);
        result*=ModInt<MOD_>(base_);
        result+=ModInt<MOD_>(str[i]);
        hash_.push_back(result);
      }
    }

  }
  __int128 GetHash(int front,int back){
    if(front>back){
      cerr<<"RollingHash::GetHash() Error: argument\"front\" is larger than \"back\""<<endl;
      abort();
    }
    if(front==0) return hash_[back].GetValue();
    ModInt<MOD_> result=hash_[back]-hash_[front-1]*ModInt<MOD_>(RepeatedPowMod(base_,back-front+1,MOD_));
    return result.GetValue();
  }
  __int128 GetBase(){
    return base_;
  }
};

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n,m;
  std::string s;
  cin>>n>>m>>s;
  std::set<__int128> hash_set;
  RollingHash rh(s,10007);
  int l=1,r=1;
  for(int i=0;i<m;i++){
    std::string query;
    cin>>query;
    if(query=="L++"){
      l++;
    }else if(query=="L--"){
      l--;
    }else if(query=="R++"){
      r++;
    }else{
      r--;
    }

    __int128 hash=rh.GetHash(l-1,r-1);
    if(hash_set.find(hash)==hash_set.end()){
      hash_set.insert(hash);
    }
  }
  cout<<hash_set.size()<<endl;



  return 0;
}



Measured memory_bytes: 26516