import java.util.Scanner; import java.util.concurrent.atomic.AtomicInteger; public class B { public static void main(String[] args) { Scanner in = new Scanner(System.in); in.nextInt(); AtomicInteger sum = new AtomicInteger(); AtomicInteger count = new AtomicInteger(); in.next().chars().map( c -> c == 'U' ? 1 : -1 ).forEach( v -> { if (sum.get() == 0 && v < 0) count.addAndGet(1); sum.addAndGet(v); }); System.out.println(count); } }