# Enter your code here. Read input from STDIN. Print output to STDOUT sc = int(raw_input()) t = raw_input() vc = 0 vs = False sl = 0 for s in t: if(s == 'U'): sl += 1 if(vs and sl == 0): vs = False vc += 1 else: if(sl == 0): vs = True sl -= 1 print vc