def main(): num = int(raw_input()) trip = raw_input() level = 0 valleys = 0 curr = 0 for i in xrange(num): if trip[i] == 'U': level += 1 elif trip[i] == 'D': level -= 1 if level == 0 and trip[i] == 'U': valleys += 1 print valleys main()