#include #include #include #include #include using namespace std; int main() { int N; cin >> N; int ret = 0; int height = 0; bool inV = false; while (N--) { char m; cin >> m; if (m == 'U') { if (height == 0) { inV = false; } height++; } else { if (height == 0) { inV = true; ret++; } height--; } } cout << ret; return 0; }