# Enter your code here. Read input from STDIN. Print output to STDOUT import sys n = sys.stdin.readline() s = sys.stdin.readline() lvl = 0 #sealvl vals = 0 for i in range(0,len(s)): if s[i] == 'D' and lvl == 0: vals = vals + 1 if s[i] == 'U': lvl = lvl + 1 elif s[i] == 'D': lvl = lvl - 1 print vals