#include #include #include #include #include using namespace std; int main() { size_t length; std::cin >> length; int elev = 0; size_t valies = 0; bool valey_started = false; std::string symbols; std::cin >> symbols; for (int i = 0; i < symbols.size (); i++) { char step = symbols [i]; if (step == 'U') elev++; else elev--; if (elev == 0 && valey_started) { valey_started = false; valies++; } else if (elev < 0 && valey_started == false) valey_started = true; } std::cout << valies; return 0; }