# Enter your code here. Read input from STDIN. Print output to STDOUT steps = int(raw_input().strip()) hills_n_valleys = raw_input().strip() sea_level = 0 valley = False total_valleys = 0 for x in hills_n_valleys: if x == 'U': sea_level += 1 if valley and sea_level == 0: total_valleys += 1 elif x == 'D': sea_level -= 1 if sea_level < 0: valley = True print total_valleys