a = input() b = input() counter = 0 level = 0 for x in range(0, len(b)): if b[x] is "U": level += 1 if level is 0: counter += 1 elif b[x] is "D": level -= 1 print(counter)