#include #include #include #define f first #define s second using namespace std; int step = 0; int valley = 0; int main(){ int n; cin >> n; for(int counter = 0; counter < n; counter++) { char x; scanf(" %c", &x); int y = (x == 'U' ? 1: -1); if(step == 0 && step + y < 0) valley++; step += y; } cout << valley << endl; return 0; }