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) { int count = 0; int seaLevel = 0; Scanner kb = new Scanner(System.in); int n = kb.nextInt(); kb.nextLine(); String s = kb.nextLine(); char[] charArr = s.toCharArray(); for(int i = 0; i < n ; i++){ if(charArr[i] == 'D'){ seaLevel -= 1; } else seaLevel += 1; if(seaLevel == -1 && charArr[i + 1] == 'U'){ count += 1; } } System.out.print(count); } }