object Main extends App {
  @scala.annotation.tailrec
  def loop(permutations: Seq[Seq[Int]], target: Seq[Int], count: Int): Option[Int] =
    permutations match {
      case Seq() => None
      case x :: _ if x == target => Some(count)
      case _ :: xs => loop(xs, target, count + 1)
    }
  val sc = new java.util.Scanner(System.in)
  val s = sc.nextInt()
  val P, Q = List.fill(s)(sc.nextInt())
  val permutations = (1 to s).permutations.toList
  val diff = for {
    p <- loop(permutations, P, 1)
    q <- loop(permutations, Q, 1)
  } yield math.abs(p - q)
  println(diff.getOrElse(0))
}
