#include #include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int num_of_cases; string steps; cin>>num_of_cases>>steps; int level = 0; int num_of_valleys = 0; bool inValy = 0; int priv_level = 0; for(int i = 0; i < num_of_cases; i++) { if(steps[i] == 'U') { priv_level = level; level++; } else if(steps[i] == 'D') { priv_level = level; level--; } if(level < 0) { inValy = 1; } else if(level>0) { inValy = 0; } if((level == 0) & (priv_level == -1)) { num_of_valleys++; } } cout<