class xnttwxn_solution():
def __init__(self,song,pos,process):
self.song = song
self.pos = pos
self.process = process
def songdan(self):
songlist = [i for i in range(1,self.song+1)]
current = 0
end = 3
for ele in self.process:
if current==0 and ele=="U":
end = self.song-1
current = self.song-1
elif current==self.song-1 and ele=="D":
end = 3
current = 0
else:
current += int(self.pos[ele])
if ele=="D" and current>end:
end+=1
if ele=="U" and current<end-3:
end-=1
result = songlist[end-3:end+1]
final = str(result).replace("[","").replace("]","").replace(",","")
print(final)
print(songlist[current])
if __name__=="__main__":
num = int(input())
process = input()
pos = {"U": -1, "D": 1}
sample = xnttwxn_solution(num,pos,process)
sample.songdan()