#include<bits/stdc++.h>
using namespace std;
long long s,n;
long long a,b,c;
stack<int>q;
int main()
{
cin>>n>>s;
int t=0;
for(int i=1;i<=n;i++)
{
char x;
cin>>x;
if(x=='L')
{
q.push(0);
}
else if(x=='R')
{
q.push(1);
}
else
{
if(q.size()==0)
{
t++;
}
else if(q.size()>0)
{
q.pop();
}
}
while(!q.empty()&&t>0)
{
int h=q.top();
if(h==0)
{
s--;
}
else
{
s++;
}
q.pop();
t--;
}
}
while(!q.empty())
{
int x=q.top();
s=s*2+x;
q.pop();
}
for(int i=1;i<=t;i++)
{
s/=2;
}
cout<<s;
}