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 n = in.nextInt(); in.nextLine(); String path = in.nextLine(); int height = 0, count = 0; boolean valleyStarted = false; for(int i = 0; i < n; i++){ char step = path.charAt(i); if(height < 0 && step == 'U' && valleyStarted){ count++; valleyStarted = false; } if(height == 0 && step == 'D'){ valleyStarted = true; } if(step =='D'){ height--; }else{ height++; } } System.out.println(count); } }