# Enter your code here. Read input from STDIN. Print output to STDOUT n = gets.to_i steps = gets sea_level = 0 valley = 0 steps.each_char do |c| if(c == 'U') sea_level = sea_level + 1 if sea_level == 0 valley = valley + 1 end elsif(c == 'D') sea_level = sea_level - 1 end end puts valley