import sys

def max_drink(n):
    max = 0
    while(n >= 3):
        new_drink = n // 3
        max += new_drink
        n = n % 3 + new_drink
    if n == 2:
        max += 1
    return max

input_data = sys.stdin.read().strip().split()
results = []
for line in input_data:
    n = int(line)
    if n == 0:
        break
    results.append(max_drink(n))
for result in results:
    print(result)