first =input() second=input() count_1 =0 count_2 =0 below_sea = False for element in range(0,len(second)): if second[element] == "U": count_1 += 1 if second[element] == "D": count_1 -=1 if count_1 < 0: if not below_sea : count_2 +=1 below_sea = True else: below_sea =False print(count_2)