#include #include #include #include #include using namespace std; int main() { int n=0, level=0, valleys=0; bool valley_start = false; cin>>n; vector steps(n); for (int i=0; i>steps[i]; if (steps[i]=='U') level++; if (steps[i]=='D') level--; if ((level < 0) && (!valley_start)) valley_start = true; else if ((level >= 0) && (valley_start)) { valleys++; valley_start = false; } // cout<