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. */ int n = 0; Scanner sc = new Scanner(System.in); int up = 0 ; n = sc.nextInt(); char a[] = sc.next().toCharArray(); int v_start = 0; int no_of_v = 0; for(int i = 0; i < n ; i++){ if (a[i] == 'U') up++; if(a[i] == 'D') up--; if(up < 0) v_start = 1; if(v_start == 1 && up == 0){ no_of_v++; v_start = 0; } } System.out.println(no_of_v); } }