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