n = int(raw_input()) l = 0 v = 0 j = False a = raw_input() for i in a: #print l if i == 'U': l+=1 else: if l == 0: v += 1 l-=1 print v