# Enter your code here. Read input from STDIN. Print output to STDOUT n = gets.strip.to_i steps = gets.strip oldLevel = 0 count = 0 for i in 0..(n-1) if steps[i] === "U" newLevel = oldLevel + 1 elsif steps[i] === "D" newLevel = oldLevel - 1 end if oldLevel === -1 && newLevel === 0 count += 1 end oldLevel = newLevel end puts count