while True: try: N = int(input()) except: break D = N while N>=3: D += N//3 N = N//3+N%3 if N==2:D += 1 print(D)