Each number is the height of a bar of width 1. After raining, how much water is trapped between the bars?
Input: one line of space-separated heights. Output: the units of trapped water.
Your program reads from stdin and prints to stdout.
Example 1
Input: 0 1 0 2 1 0 1 3 2 1 2 1
Output: 6
Hints