#include<stdio.h>
#include<string.h>
int main(void)
{
    int num=0;
    scanf("%d",&num);
    char str[101]={0};
    scanf("%s",&str);
    //int a[160]={0};
    int b[4]={0};
    /*for(int i=0;i<num;i++)
    {
        a[i]=i+1;
    }*/
    for(int i=0;i<num&&i<4;i++)
    {
        b[i]=i+1;
    }
    //printf("%d\n",b[3]);
    int len=strlen(str);
    int j1=1;//实际光标位置
    int j2=0;//窗口第一个在b数组中位置
    for(int i=0;i<len;i++)
    {
       if(str[i]=='U')
       {
           if(j1==1&&b[0]==1&&num>=4)
           {
               j1=num;
               b[0]=num-3;
               b[1]=num-2;
               b[2]=num-1;
               b[3]=num;
               j2=3;
           }
           else if(j1==1&&b[0]==1&&num<4)
           {
               j1=num;
               j2=num-1;
           }
           else if(j1!=1&&j2==0)
           {
               for(int k=0;k<4;k++){b[k]--;}
               j2=0;
               j1--;
           }
           else if(j1!=1&&j2!=0)
           {
               j1--;
               j2--;
           }
       }
        else if(str[i]=='D')
        {
            if(j1==num&&b[3]==num&&num>=4)
           {
               j1=1;
               b[0]=1;
               b[1]=2;
               b[2]=3;
               b[3]=4;
               j2=0;
           }
           else if(j1==num&&b[3]==0&&num<4)
           {
               j1=1;
               j2=0;
           }
           else if(j1!=num&&j2==3)
           {
               for(int k=0;k<4;k++){b[k]++;}
               j2=3;
               j1++;
           }
           else if(j1!=num&&j2!=3)
           {
               j1++;
               j2++;
           }
        }
    }
    for(int i=0;i<4&&i<num;i++)
    {
        printf("%d ",b[i]);
    }
    printf("\n");
    printf("%d",j1);//第二行输出
    return 0;
}