import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
// while (in.hasNextInt()) { // 注意 while 处理多个 case
// int a = in.nextInt();
// int b = in.nextInt();
// System.out.println(a + b);
// }
int n = in.nextInt();
String line = in.next();
int len = line.length();
int index = 0;
int[] currentPage = new int[4];
for (int i = 0; i < 4; i++) {
currentPage[i] = i;
}
for (int i = 0; i < len; i++) {
char c = line.charAt(i);
if (c == 'U' && index == 0) {
index = n - 1;
int temp = 0;
if (n > 4) {
for (int j = index - 3; j <= index; j++) {
currentPage[temp] = j;
temp++;
}
}
} else if (index != 0 && c == 'U' && (index - currentPage[0]) % 4 == 0) {
index--;
int temp = 0;
for (int j = index; j < index + 4; j++) {
currentPage[temp] = j;
temp++;
}
} else if (index != 0 && c == 'U' && (index - currentPage[0]) % 4 != 0) {
index--;
}
if (c == 'D' && index == n - 1) {
index = 0;
if (n > 4) {
int temp = 0;
for (int j = 0; j < 4; j++) {
currentPage[j] = j;
}
}
} else if (index != n - 1 && c == 'D' && (index - currentPage[0]) % 4 == 3) {
index++;
int temp = 0;
for (int j = index - 3; j <= index; j++) {
currentPage[temp] = j;
temp++;
}
} else if (index != n - 1 && c == 'D' && (index - currentPage[0]) % 4 != 3) {
index++;
}
}
int min = Math.min(n, 4);
for (int i = 0; i < min; i++) {
System.out.print(currentPage[i] + 1 + " ");
if (i == min - 1) {
System.out.println();
}
}
System.out.print(index + 1);
}
}