while 1: n = int(input()) if n == 0: break cnt = 0 while n >= 3: cnt += n//3 n = n%3+n//3 if n == 2: cnt += 1 print(cnt)