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