count = int(raw_input()) hike = raw_input() level = 0 valleys = 0 for i in xrange(count): prev = level if hike[i] == 'U': level += 1 if hike[i] == 'D': level += -1 if prev >= 0 and level < 0: valleys += 1 print valleys