#!/usr/bin/env python3
from math import ceil

n = None

while True:
    zhivago = input().strip()
    if zhivago == "I give up":
        break

    bot_move = int(zhivago)
    # sets the first input as the total amount of coins
    if n == None:
        n = bot_move
    else:
        n = n - bot_move

    # formula for calculating the perfect move
    order = int(ceil(n / 4))
    remainder = 1 + ((order - 1) * 4)
    move = n - remainder
    # updates the pile and prints the move made
    n = n - move
    print(move, flush=True)
    