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) { if(st.charAt(i)=='D'){ count--; }else if(st.charAt(i)=='U'){ count++; } if(count<0){ if(st.substring(i,i+3).equals("DDU")){ //System.out.println(""+st.substring(i,i+2)); vally++; } } } } System.out.println(""+vally); }