#include #include #include #include int main(void) { int n; scanf("%i", &n); char steps[n]; scanf("%s", steps); int sealvl = 0; int counter = 0; for( int i = 0; i < n; i++ ) { if( ( sealvl == 0 ) && ( steps[i] == 'D' ) ) { counter++; } if( steps[i] == 'U' ) { sealvl++; }else { sealvl--; } } printf("%i\n", counter); return 0; }