import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); scan.nextLine(); String sequence = scan.nextLine(); int count = 0; int altitude = 0; for (int i = 0; i < n; i++) { char step = sequence.charAt(i); if (altitude == 0 && step == 'D') { count++; } if (step == 'U') { altitude++; } else if (step == 'D') { altitude--; } } System.out.println(count); } }