#include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int test, sum = 0, count = 0; char c; bool flag = 1; cin >> test; c = getchar(); while(test--) { c = getchar(); if(c == 'U') ++sum; else if(c == 'D') --sum; if(sum == 0) flag = 1; else if(flag && sum < 0) { ++count; flag = 0; } } printf("%d", count); return 0; }