11208 - MaxPath   

Description

Input a complete binary tree where each node has an non-negative weight value w, which is called node weight. Path weight is defined as the summation of node weights in a root-to-leaf path. Please calculate the maximum path weight in the tree.

Input

There are lots of complete binary trees in the input. Each tree occupies a line. Tree height is smaller than 10.

Output

For each tree, output the maximum path weight in a line.

Sample Input  Download

Sample Output  Download

Tags




Discuss