# [Wolfram Language (Mathematica)], <s>53</s> 46 bytes Tr[1^{0}~Union~Accumulate@Sign@Differences@#]& [Try it online!][TIO-k9uc9955] Thanks to @J42161217 for pointing out that `Tr[1^list]` is a 1-character-shorter alternative to `Length@list`. [Wolfram Language (Mathematica)]: https://www.wolfram.com/wolframscript/ [TIO-k9uc9955]: https://tio.run/##VY3LCsIwEEX3fkVBcNVFWptHF0IEP0BQV6VCCIkGbISarkr763ECU6WQy82dx5lOhafpVHBaRXuI174p7iOZ5pt3bz8ftR664aWCkRf38PLkrDW98dp85LbdxXPvfJC2GUme4Zvaza9a7fOsEn/REkTwv5oULM8EVEUFKkCwyWsQZA49DpssZegxDkoZegxoFDKt0WGW0hW5RJJA0uKJnK4QJDIkLp4uFFMbvw "Wolfram Language (Mathematica) – Try It Online"