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 input = new Scanner(System.in); int steps = input.nextInt(); input.nextLine(); String upAndDown = input.nextLine(); input.close(); int[] path = new int[steps]; int level = 0; int count = 0; for (int i=0;i < steps;i++){ //System.out.println(upAndDown.charAt(i)); if (upAndDown.charAt(i)=='D'){ path[i] = -1; } if (upAndDown.charAt(i)=='U'){ path[i] = 1; } level = level + path[i]; if (level==0 && path[i]==1){ count++; } } System.out.print(count); } }