#include #include #include #include #include using namespace std; int main() { int n; cin >> n; int x = 0; int v = 0; for (int i = 0; i < n; i++) { char c; cin >> c; if (c == 'U') { x++; } else { x--; } if (x == 0 && c == 'U') { v++; } } cout << v; return 0; }