#include #include #include #include #include using namespace std; int main() { int num_steps = 0; string steps; cin>> num_steps; cin>>steps; int num_valleys = 0; int running_sum = 0; bool in_valley = false; for(int i = 0; i < num_steps; ++i){ char in = steps[i]; if(in == 'U'){ running_sum += 1; if(in_valley && running_sum == 0) ++num_valleys; } if(in == 'D'){ running_sum -= 1; if(running_sum == -1) in_valley = true; } } cout<