import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); String s = input.next(); valleys(s); } public static void valleys(String s){ int seaLevel = 0; int valleys = 0; boolean underSeaLevel = false; int sL = s.length(); for(int i = 0; i < sL ; i++){ if(seaLevel == 0 && underSeaLevel == true){ underSeaLevel = false; } else if(seaLevel < 0 && underSeaLevel == false){ underSeaLevel = true; valleys ++; } if(s.charAt(i) == 'U' ){ seaLevel++; } else if(s.charAt(i) == 'D'){ seaLevel--; } } System.out.println(valleys); } }