#include #include #include #include #include #include using namespace std; int main() { int N; string steps; int vallies = 0; bool isValley = false; int c = 0; cin >> N; cin >> steps; for(int i = 0; i < steps.size(); i ++){ if(c < 0){ isValley = true; } if(steps[i] == 'U'){ c ++; }else if(steps[i] == 'D'){ c --; } if(c == 0){ if(isValley){ vallies ++; isValley = false; } } } cout << vallies; return 0; }