CodeMentor.
Ask AIProblemsLearnC++TCSCore CSHRProgress
0Lv 1
ProblemsHackerRank Warmup

Counting Valleys

Easy
HackerRank
12/12
EasyHackerRank Warmup

Counting Valleys

U is +1, D is -1. A valley is a step sequence that starts below sea level and returns to 0.

Examples

Example 1

Input

8
UDDDUDUU

Output

1

Stuck? Take a nudge

C++17Autosaves