#include <stdio.h>
#include <iostream>
#define int long long
int n, m, now = 200000, ans, k;
bool flag[300010];
int t[100010], id[300010];
int cnt[10][300010], sum[10];
char a[100010];
signed main() {
scanf("%lld%lld", &n, &m);
for (int i = 1; i <= n; i++)
scanf("%lld", t + i), t[i] += 200000, id[t[i]] = i;
for (int i = 1; i <= m; i++) {
scanf("%c", a + i);
if (a[i] == 'L')
now--;
if (a[i] == 'R')
now++;
if (a[i] == 'F' && id[now] && !flag[now])
k++, flag[now] = 1;
}
for (int k = -2; k <= 2; k++) {
if (!k)
continue;
now = k + 200000;
for (int i = 1; i <= m; i++) {
if (a[i] == 'L')now--;
if (a[i] == 'R')now++;
if (a[i] == 'F')
if (id[now])
cnt[k + 2][now]++, sum[k + 2] += (cnt[k + 2][now] == 1);
}
}
now = 200000;
for (int i = 1; i <= m; i++) {
if (a[i] == 'L')
ans = std::max(ans, sum[4]), ans = std::max(ans, sum[3] + (id[now] > 0 && !cnt[3][now]));
if (a[i] == 'R')
ans = std::max(ans, sum[0]), ans = std::max(ans, sum[1] + (id[now] > 0 && !cnt[1][now]));
if (a[i] == 'F')
ans = std::max(ans, sum[1] - (id[now] > 0 && cnt[1][now] == 1)), ans = std::max(ans, sum[3] - (id[now] > 0 && cnt[2][now] == 1));
if (a[i] == 'L') now--;
if (a[i] == 'R') now++;
if (a[i] == 'F') {
for (int j = -2; j <= 2; j++) {
if (!j)continue;
if (id[now])cnt[j + 2][now]++, sum[j + 2] += (cnt[j + 2][now] == 1);
if (id[now + j])cnt[j + 2][now + j]--, sum[j + 2] -= (!cnt[j + 2][now + j]);
}
}
}
printf("%lld", std::max(ans, k));
return 0;
}