#include #include #include #include #include using namespace std; int main() { int d; cin >> d; char* tab = new char[d]; for(int i = 0; i < d; ++i) cin >> tab[i]; int p = 0, x = 0; for(int i = 0; i < d; ++i){ if (tab[i] == 'U') p++; else{ p--; if(p == -1) ++x; } } cout << x; return 0; }