The most obvious solution is: << 3 DUPN * SWAP ROT * + SWAP ROT * + 2 * >>. However,
Joe Horn has
a better solution. It is based on factoring of the equation to S = 2(d(h + w) + hw). So, here
is the program. Note it uses LASTARG: << * LASTARG + ROT * + 2 * >>