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) { Scanner sc = new Scanner(System.in); int steps = sc.nextInt(); String seq = sc.next(); int height = 0; int valleys = 0; int prevHeight = 0; for(int i = 0;i < seq.length() ; i++) { Character c = seq.charAt(i); if(c == 'U') { ++height; }else if(c == 'D') { --height; } if(height < 0 && prevHeight == 0) { ++valleys; } prevHeight = height; } System.out.println(valleys); } }