#include #include #include #include #include using namespace std; int main() { int n, count = 0, down = 0; char c; scanf("%d\n", &n); for (int i = 0; i < n; i++) { scanf("%c", &c); if (down == 0 && c == 'D') count++; if (c == 'U') { down++; } else { down--; } } printf("%d", count); return 0; }