#include #include #include #include int main() { int elevation = 0; int valleyCount = 0; int n; scanf("%d", &n); getchar(); char step; for(int i = 0; i < n; i++) { scanf("%c", &step); if(step == 'U') { if(elevation == -1) { valleyCount++; } elevation++; } else { elevation--; } } printf("%d", valleyCount); return 0; }