import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; 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 n = input.nextLine(); int tracker = 0; int prevtracker = 0; int valleys = 0; for(int i = 0; i < steps; i++){ prevtracker = tracker; if(n.charAt(i) == 'D'){ tracker--; } else if(n.charAt(i) == 'U'){ tracker++; } if(tracker == 0 && prevtracker == -1){ valleys++; } } System.out.println(valleys); } }