import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int steps = Integer.valueOf(br.readLine()); char [] direction = br.readLine().toCharArray(); int level = 0; int valley = 0; for(int i = 0; i < steps; i++){ if(direction[i] == 'U') { level++; if(level == 0) { valley ++; } } else { level--; } } System.out.println(valley); } }