import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ int numValleys = 0; int seaLevel = 0; Boolean valley = false; Scanner in = new Scanner(System.in); int n = in.nextInt(); String line = in.next(); for (int i = 0; i < n; i++){ if(line.charAt(i) == 'D'){ seaLevel --; } else { seaLevel ++; } if (valley && seaLevel == 0) { numValleys++; } if (seaLevel < 0) { valley = true; } else { valley = false; } } System.out.println(numValleys); } }