N = int( input() ) ans = "" while N: ans += chr( ord( '0' ) + N % 7 ) N //= 7 for i in range( len( ans ) - 1, -1, -1 ): print( ans[ i ], end = "" )