while True:
try:
# 获取当前所拥有的的空瓶子
num = int(input())
# k:用来记录喝的饮料的总瓶数
k = 0
# 如果输入为零,代表结束,直接跳出这个循环
if num == 0:
break
while num != 1 and num != 2:
# i代表取余的结果;
i = num % 3
# j代表整除3的结果
j = num // 3
k += j
num = i + j
if num == 2:
k += 1
print(k)
except:
break
try:
# 获取当前所拥有的的空瓶子
num = int(input())
# k:用来记录喝的饮料的总瓶数
k = 0
# 如果输入为零,代表结束,直接跳出这个循环
if num == 0:
break
while num != 1 and num != 2:
# i代表取余的结果;
i = num % 3
# j代表整除3的结果
j = num // 3
k += j
num = i + j
if num == 2:
k += 1
print(k)
except:
break