# Enter your code here. Read input from STDIN. Print output to STDOUT num = input() hike = map(lambda x: 1 if x=='U' else -1, list(raw_input())) loc = 0 valley = 0 for i in xrange(num): loc = loc + hike[i] if loc == 0 and hike[i]>0 : valley = valley + 1 print valley