#include <iostream>
using namespace std;

int main() {
    int n;

    string str;
    while(cin>>n>>str){

        int num=1;
        int window_a=1;
        int window_b=min(4,n);
        for(int i=0;i<str.size();i++){
            if(str[i]=='U'){
                num=(num-1-1+n)%n +1;}
                else if(str[i]=='D'){
                    num=num%n+1;
                } 
                if(num<window_a){
                    window_a=num;
                    window_b=num+3;
                }else if(num>window_b){
                    window_b=num;
                    window_a=num-3;
                }
            }
           
             for(int i=window_a;i<=window_b;i++){
            cout<<i<<" ";}
             cout<<endl<<num;

        }
   } 

// 64 位输出请用 printf("%lld")