BEGIN { FS=" " }
/forward/ { h_pos += $2 }
/down/ { depth += $2 }
/up/ { depth -= $2 }
END { print depth * h_pos }