n = int(input()) t = input() height, valleys = 0, 0 for i in t: if i == "U": height += 1 if height == 0: valleys +=1 else: height-=1 print(valleys)