#include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int currentLevel = 0, numValleys = 0, numSteps; cin >> numSteps; for (int i = 0; i < numSteps; i++) { char step; cin >> step; if (step == 'U') { currentLevel++; if (currentLevel == 0) numValleys++; } else currentLevel--; } cout << numValleys; return 0; }