import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int valley = 0; int count = 0; String str = sc.next(); char c; for(int i = 0; i < n; i++) { c = str.charAt(i); if(c == 'D') valley--; else if(c == 'U') valley++; if(valley == 0 && c == 'U') count++; } System.out.print(count); } }