#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
long long process_consecutive_U(long long current, int count) {
for (int i = 0; i < count && current > 1; i++) {
current /= 2;
}
return current;
}
long long process_consecutive_LR(long long current, const string& moves, int start, int end) {
for (int i = start; i <= end; i++) {
if (moves[i] == 'L') {
current = current * 2;
} else {
current = current * 2 + 1;
}
}
return current;
}
long long solve(int n, long long s, const string& moves) {
long long current = s;
int i = 0;
while (i < n) {
if (moves[i] == 'U') {
int j = i;
while (j < n && moves[j] == 'U') {
j++;
}
current = process_consecutive_U(current, j - i);
i = j;
}
else {
int j = i;
while (j < n && moves[j] != 'U') {
j++;
}
current = process_consecutive_LR(current, moves, i, j - 1);
i = j;
}
}
return current;
}
int main() {
int n;
long long s;
string moves;
cin >> n >> s;
cin >> moves;
long long result = solve(n, s, moves);
cout << result << endl;
return 0;
}