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(); String order = sc.next(); char steps[]= order.toCharArray(); if(n>order.length()){ System.out.println(-1); System.exit(1); } int valley=0,mountain =0,counter =0; for(int i=0;i< n ;i++){ if(counter ==0){ if(steps[i]=='U'){ mountain++; counter++; } else{ valley++; counter--; } } else{ if(steps[i]=='U'){ counter++; } else{ counter--; } } } System.out.println(valley); System.exit(0); /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ } }