from collections import deque

s = input()
normal = deque()
priority = deque()
number = 1
for c in s:
	if c == 'Z':
		normal.append(number)
		number += 1
	if c == 'P':
		priority.append(number)
		number += 1
	if c == 'G':
		if priority:
			print(priority.popleft())
		else:
			print(normal.popleft())
