import re a = input() data = input() walk = data.replace("U"," +1").replace("D"," -1").split(" ") f = [int(x) for x in walk[1:]] sum = 0 valeys = 0 mountains = 0 for i in range(len(f)): sum = sum + f[i] if sum == 0 and f[i] > 0 : valeys +=1 if sum == 0 and f[i] < 0 : mountains += 1 print(valeys)