#include #include using namespace std; int main() { int n; int elevation = 0; int valley = 0; int mountain = 0; cin >> n; vector step(n); for ( int i = 0; i < n; i ++) { cin >> step[i]; if (step[i] == 'U' || step[i] == 'u') { elevation += 1; } if (step[i] == 'D' || step[i] == 'd') { elevation -= 1; } if (elevation == 0 ) { if (step[i] =='D' || step[i] == 'd') mountain += 1; else valley += 1; } } cout << valley; return 0; }