#include #include #include #include #include using namespace std; int main() { int height = 0; int valleys = 0; char step; int n; cin >> n; for (int i = 0; i> step; if (step == 'U'){ height++; if (height == 0) { valleys++; } } else { height--; } } cout << valleys; return 0; }