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