n = int(input().strip()) arr = str(input().strip()) level = 0 count = 0 for i in range(0, n): if arr[i] == 'U': level += 1 elif arr[i] == 'D': if level == 0: count += 1 level -= 1 print(count)