#include <iostream>
#include <list>
using namespace std;
int main()
{
int n;
string cmd;
while (cin >> n >> cmd)
{
int index = 1, top = 1;
for(auto i:cmd)
{
if(i=='D')
{
index++;
if(index>n)index = top = 1;//回到第一首
else if(index>top+3)top++;//下滑
}
else
{
index--;
if(index==0){index = n;top = max(n-3,1);}//到最后一首
else if(index<top)top--;//上滑
}
}
for(int i=0;i<4;i++)if(top+i<=n)cout<<top+i<<" ";
cout << endl << index << endl;
}
}