# Enter your code here. Read input from STDIN. Print output to STDOUT n=raw_input() n=int(n) way=raw_input() height=0 count=0 for i in range(n): if way[i]=="D": height-=1 else: height+=1 if height==0 and way[i]=="U": count+=1 print count