---
# System prepended metadata

title: Bricks and Sand

---

# Bricks and Sand

Jenny, a young child, is playing in the garden and has arranged multiple bricks on one another at different heights. The difference in height leads to gaps in the structure. For example, if the height of the bricks is `2 0 2 0 1`,

<img style="width:300px" src="https://new-assets.ccbp.in/frontend/content/python-idp/bricks-and-gaps-cp.png" alt="bricks and gaps"/>

<br/>

Jenny wants to fill these gaps with sand from their backyard. Help Jenny by finding out the number of gaps that need to be filled with sand.

Write a program that reads a list of the heights of the bricks and prints the number of gaps that need to be filled with sand.

---

#### Input

The input will be a single line containing space-separated numbers representing the heights.

---

#### Output

The output should be a single line containing an integer that is the number of gaps that need to be filled with sand.

---

#### Explanation

For example, if the given list is `0 1 2 1 2 3 1 0 1 2 0 1`,

<img style="width:400px" src="https://new-assets.ccbp.in/frontend/content/python-idp/bricks-and-sand-cp.png" alt="bricks and sand"/>

- There are **6** gaps to be filled with sand.

The output should be **6**.


----

#### Test cases

**Sample Input 1**

**Input:** `0 1 2 1 2 3 1 0 1 2 0 1`
**Output**: `6`

**Sample Input 2**

**Input:** `6 4 2 5 4 7`
**Output:** `9`
