import java.util.Scanner; public class Solution { public static void main(String[] args) throws Exception{ // BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Scanner scanner = new Scanner(System.in); String N = scanner.nextLine(); String str=scanner.nextLine(); int current=0; int previous=0; int val=0; for (int i = 0; i < str.length(); i++) { // System.out.println("hello world"); previous=current; char c=str.charAt(i); if(c=='U'){ current++; }else{ current--; } if(current==-1 && previous==0){ val++; } } System.out.println(val); } }