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 in = new Scanner(System.in); int totalSteps = in.nextInt(); String stepSequence = in.next(); in.close(); int[] levels = new int[totalSteps+1]; levels[0] = 0; char[] charArr = stepSequence.toCharArray(); for ( int i = 0; i < charArr.length; i ++ ) { if ( charArr[i] == 'U') levels[i+1] = levels[i] + 1; if ( charArr[i] == 'D') levels[i+1] = levels[i] - 1; } int valleyCount = 0; for ( int i = 1; i < levels.length; i ++ ) { if ( levels[i-1] == -1 && levels[i] == 0 ) valleyCount++; } System.out.println(valleyCount); } }