#include #include #include #include #include using namespace std; int main() { int n; cin >> n; string str; cin >> str; int l = 0; int val = 0; char ps; for(int i = 0; i < n; i++){ if(str[i] == 'U'){ l++; //cout << l << endl; ps = 'U'; } if(str[i] == 'D'){ l--; //cout << l << endl; ps = 'D'; } if(ps == 'U' && l == 0){ val++; } } cout << val << endl; return 0; }