enum Step: Int { case up = 1 case down = -1 } let numSteps = Int(readLine()!)! let steps = readLine()!.characters.map({ $0 == "U" ? Step.up : Step.down }) var elevation = 0 var valleys = 0 for step in steps { if step == Step.down && elevation == 0{ valleys += 1 } elevation += step.rawValue } print(valleys)