#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 3, mod = 998244353;
int a[N], b[N];
int n, m;
void slv1(){
    cin >> n >> m;
    for (int i = 0 ;i < n; i++){
        cin >> a[i];
        b[i] = a[i];
        if (i % 2 == 0){
            if ((i + a[i]) % 2 != (a[0]) % 2){
                cout << "No";
                exit(0);
            }
        } else {
            if ((i + a[i]) % 2 == (a[0] % 2)){
                cout << "No";
                exit(0);
            }
        }
    }
    cout << "Yes\n";
}
int tp[N];
string s;
int res(vector<int> ch){
    for (int i = 0 ;i < n; i++){
            a[i] = b[i];
        if (s[i] == 'L'){
            tp[i] = -1;
        } else {
        tp[i] = 1;}
    }

    vector<pair<int, int>> rem;
    bool f = true;
    for (int i : ch){
        if (a[i] != a[ch[0]]){
            f = false;
        }
    }
    if (f){
        rem.push_back({a[ch[0]], 0});
    }
    for (int k = 0 ;k < 10 * m - 1; k++){
        for (int i : ch){
            if (a[i] + tp[i] > m || a[i] + tp[i] < 1){
                tp[i] = -tp[i];
                a[i] += tp[i];
            } else {
                a[i] += tp[i];
            }
        }
        f = true;
        for (int i = 0 ;i < n; i++){
            if (a[i] != a[ch[0]]){
                f = false;
            }
        }
        if (f){
            rem.push_back({a[ch[0]], k + 1});
        }
    }
    sort(rem.begin(), rem.end());
    if (rem.empty()){
        return -1;
    }
    return rem.back().first;
}
signed  main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    if (t >= 1){
        slv1();
    }
    cin >> s;
    if (t >= 2){
        if (n == 2){
            cout << res({0, 1});
        } else {
            int r = res({0, 1, 2});
            if (r == -1){
                cout <<max({min(res({0, 1}), res({1, 2})), min(res({0, 1}), res({0, 2})), min(res({0, 2}), res({1, 2}))});

            } else {
                cout << r;
            }
        }
    }

}

