哎,边界条件,0起1起傻傻分不清

n = int(input())

def move_large_4(pos, screen_head, direction, total):
    if direction == "U":
        if pos == screen_head:  # 当前光标在第一位
            if screen_head == 0:  # 如果是第一首
                return total-1, total-4
            else:
                return pos-1, screen_head-1
        else:
            pos -= 1
    elif direction == "D":
        if pos == screen_head+3:  # 当前光标在最后一位
            if screen_head == total-4:  # 如果是最后一首
                return 0, 0
            else:
                return pos+1, screen_head+1
        else:
            pos += 1
    return pos, screen_head

def move_less_4(pos, direction, total):
    if direction == "U":
        pos -= 1
    elif direction == "D":
        pos += 1
    return pos % total, 0

direction_str = input()
curr_pos, curr_screen_head = 0, 0
for each in direction_str:
    if n > 4:
        curr_pos, curr_screen_head = move_large_4(curr_pos, curr_screen_head, each, n)
    else:
        curr_pos, curr_screen_head = move_less_4(curr_pos, each, n)

# +1是为了对齐下标和序号
result = [str(curr_screen_head+each+1) for each in range(min(4, n))]
print(" ".join(result))
print(curr_pos+1)