#include #include #include #include int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n, dcnt = 0, ucnt = 0, vcnt = 0; char ch; int vstart = 0; scanf("%d\n", &n); while(EOF!=(ch=fgetc(stdin)) && ch != '\n'){ if (ch == 'D') dcnt++; else if (ch == 'U') ucnt++; if (dcnt > ucnt && !vstart) { vstart = 1; } else if (dcnt == ucnt && vstart) { vcnt++; vstart = 0; } } printf ("%d\n", vcnt); return 0; }