#include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n; std::cin >> n; char step; int valley = 0, height = 0; while(std::cin >> step){ step=='U'? height++ : height--; if(height == 0 && step == 'U') valley++; } std::cout << valley; return 0; }