#include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int a[1000000] ; char ch; long int i,n,val = 0,c = 0, tog = 0,f = 0; cin>>n; for (i=0;i>ch; if (ch == 'U') { a[i] = ++val; } else if (ch == 'D'){a[i] = --val; } if (val == -1 && ch == 'D' && !tog ) {tog = 1;} else if (val == 0 && tog && ch == 'U') {c++; tog = 0;} } printf("%d",c); return 0; }