def valleycount(climb): sealevel = 0 counter = 0 for letter in climb: if sealevel == 0 and letter == 'D': counter+=1 sealevel-=1 elif letter == 'U': sealevel+=1 else: sealevel-=1 print counter n = raw_input() path = list(raw_input()) valleycount(path)