import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); char[] steps = new char[n]; String stepString = scanner.next(); steps = stepString.toCharArray(); int step1 = 0,step2 = 0, v = 0 ; for(int i = 0; i < steps.length; i++){ if(steps[i] == 'D'){ step2 = step2-1; } if(steps[i] == 'U'){ step2 = step2 + 1; } if(step1 == 0 && step2 < 0){ v++; } step1 = step2; } System.out.println(v); } }