# Programmer: Sriram Pemmaraju
# Date: Feb 13th, 2012
# This program computes the ternary equivalent of a given
# non-negative integer n.

n = int(raw_input("Please type a non-negative integer. "))
originalN = n # Store of a copy of n for use later

# Treat n equals 0 as a separate case
if n == 0:
    suffix = "0"
else: 
    # Here n > 0
    suffix = ""
    # This loop repeatedly pulls out the last digit of the
    # ternary equivalent
    while n > 0:
        suffix = str(n % 3) + suffix
        n = n / 3

print "The ternary equivalent of", originalN, "is", suffix 
