lis = []
while True:
num = input()
if num == "0":
break
else:
lis.append(num)
lis1 = []
for n in lis:
tatol = 0
n = int(n)
while n >= 3:
a_int = n // 3
tatol += a_int
a_left = n - 3 * a_int
n = a_int + a_left
if n == 2:
tatol += 1
else:
lis1.append(tatol)
for ans in lis1:
print(ans)