#include #include #include #include int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n; scanf("%d",&n); char str[n+1]; scanf("%s",str); int count = 0; int pre = 0; int valley = 0; for(int i=0;i<=n-1;i++){ if(str[i] == 'U'){ count++; } else{ count--; } if(count == -1 && pre == 0){ valley++; } pre = count; } printf("%d",valley); return 0; }