#include #include #include #include #include #include using namespace std; int main() { int n; string str; cin >> n; cin >> str; int height = 0, count = 0; for (const auto& step : str) { if (step == 'U') { height++; } else if (step == 'D') { if (height == 0) count++; height--; } } cout << count; return 0; }