n = int(input().strip()) walk = (input().strip()) sealevel = 0 valleycount =0 for x in walk: if x=="U": sealevel+=1 elif x=="D": if sealevel==0: valleycount+=1 sealevel-=1 print (valleycount)