# Enter your code here. Read input from STDIN. Print output to STDOUT n = int(input()) s = raw_input() lvl = 0 cnt = 0 for i in s: if lvl == 0 and i == 'D': cnt += 1 lvl -= 1 elif i == 'U': lvl += 1 else: lvl -= 1 print cnt