#include #include #include #include #include using namespace std; int main() { int n; cin >> n; int current = 0, valleys = 0; char value; for(int i = 0; i < n; i++){ cin >> value; if( value == 'D'){ if( current == 0 ){ valleys++; } current--; }else if( value == 'U'){ current++; } } cout << valleys; return 0; }