import java.io.*; import java.util.*; 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. */ Scanner scan = new Scanner(System.in); int numSteps = Integer.parseInt(scan.nextLine()); int numValleys = 0; int elevation = 0; String pathString = scan.nextLine(); scan.close(); for(int i = 0; i < numSteps; i++){ if(pathString.charAt(i) == 'D'){ if(elevation == 0){ numValleys++; } elevation--; }else{ elevation++; } } System.out.print(numValleys); } }