object Main extends App {
  import scala.collection.mutable
  import scala.io.StdIn._

  val str = 'A' +: readLine.trim
  println(str.indices.tail.count(i ⇒ str(i) <= str(i - 1)))
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}
