import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner sc = new Scanner(System.in); int numSteps = sc.nextInt(); String steps = sc.next(); int seaLevel = 0, valleys = 0, mountains = 0; for( int i = 0; i < numSteps; i++ ) { char lastStep = steps.charAt(i); if( lastStep == 'U' ) { seaLevel++; } else if ( lastStep == 'D' ) { seaLevel--; } if( seaLevel == 0 && lastStep == 'U' ) { valleys++; } if( seaLevel == 0 && lastStep == 'D' ) { mountains++; } } System.out.println(valleys); } }