import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); String b = sc.nextLine(); char[] a = b.toCharArray(); int v = 0; int seaLevel = 0; for (int i = 0; i < n; i++) { if (a[i] == 'U') { v = (++seaLevel == 0) ? ++v : v; } else { seaLevel--; } } System.out.println(v); } }