#include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int numSteps; cin >> numSteps; int level = 0; int valleyCount = 0; char step; bool inValley = false; while (cin >> step) { if (level < 0) { inValley = true; } if (step == 'U') { level++; if (level == 0) { inValley = false; valleyCount++; } } else { level--; } } cout << valleyCount; return 0; }