#include #include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int rawInput,n , cnt_val = 0 , result = 0; char c; cin>>n ; while(n-->0 ){ cin >> c; if(c=='U') { cnt_val ++ ; } else if(c=='D'){ cnt_val -- ; if(cnt_val == -1){ result ++ ; } } } cout << result; return 0; }