#include #include #include #include #include using namespace std; int main() { int n; string steps; cin >> n >> steps; int loc = 0; int count = 0; for(int i = 0; i < n; i++) { char step = steps[i]; if(loc == -1 && step == 'U') { count ++; loc++; } else if(step == 'U') { loc++; } else { loc--; } } cout << count; return 0; }