# Enter your code here. Read input from STDIN. Print output to STDOUT le=int(raw_input()) stepstr = raw_input() sea = 0 val = 0 maybev = False for let in stepstr: if let == 'U': sea += 1 if let == 'D': sea -= 1 if sea == 0 and maybev: val+=1 maybev = False if sea < 0 and not maybev: maybev = True print val