(* Enter your code here. Read input from STDIN. Print output to STDOUT *) uses math; const fi=''; fo=''; var f:text; res,n,i,j,right,left:longint; c:char; a:array[0..1000001]of longint; //b:array[0..100001] of char; begin assign(f,fi); reset(f); res:=0; readln(f,n); a[0]:=0; a[n+1]:=0; for i:=1 to n do begin read(f,c); if c='U' then a[i]:=a[i-1]+1; if c='D'then a[i]:=a[i-1]-1; end; close(f); left:=0; right:=0; { for i:=1 to n-1 do for j:=1+i to n do if (a[i] = -1) and (a[i-1]=0) then if (a[j] = -1) and ( a[j+1] =0 ) then inc(res); } for i:=1 to n-1 do begin if (a[i-1]= 0) and (a[i] = -1) then inc(left); if (a[i]=-1 ) and (a[i+1]=0) then inc(right); end; assign(f,fo); rewrite(f); res:=math.min(left,right); writeln(f,res); close(f); end.