#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int t,c,x,h1[N],h2[N],h3[N][5],pre[N],suf[N][5],h[N][5],p[N];
string s;
int main(){
ios::sync_with_stdio(0);
cin>>t>>c;
while(t--) cin>>x,h1[x+c]=1;
cin>>s;s=" "+s;p[0]=c;
for(int i=1;i<=c;i++){
pre[i]=pre[i-1];p[i]=p[i-1];
if(s[i]=='L') p[i]--;
else if(s[i]=='R') p[i]++;
else pre[i]+=(h1[p[i]]&&!h2[p[i]]),h2[p[i]]++;
}
int ans=pre[c];
if(s[c]=='F') h2[p[c]]--;
for(int i=c;i>=1;i--){
if(s[i-1]=='F') h2[p[i-1]]--;
for(int j=0;j<=4;j++){
suf[i][j]=suf[i+1][j];
if(p[i]+j-2>=0&&!h3[p[i]+j-2][j]&&!h2[p[i]+j-2]&&h1[p[i]+j-2]){
if(s[i]=='F'){
h3[p[i]+j-2][j]=1;
suf[i][j]++;
}else h[i][j]=1;
}
}
}
for(int i=1;i<=c;i++){
if(s[i]=='L') ans=max(ans,max(pre[i-1]+suf[i][4],pre[i-1]+suf[i][3]+h[i][3]));
else if(s[i]=='R') ans=max(ans,max(pre[i-1]+suf[i][0],pre[i-1]+suf[i][1]+h[i][1]));
else ans=max(ans,max(pre[i-1]+suf[i+1][1],pre[i-1]+suf[i+1][3]));
}
cout<<ans;
return 0;
}