#include #include #include #include #include #include #include using namespace std; const int MaxN = 1000000+64; int h[MaxN]; char s[MaxN]; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n,len,cnt; cin >> n >> s+1; len = strlen(s+1),cnt = h[0] = 0; for(int i = 1;i <= n;i++){ if(s[i] == 'U') h[i] = h[i-1] +1; else if(s[i] == 'D') h[i] = h[i-1]-1; if(s[i] == 'D' && h[i-1] == 0) cnt ++; } cout << cnt << endl; return 0; }