object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, m = sc.nextLong()

  val mod = 1000000007

  def plus(a: Long, b: Long): Long = (a + b) % mod
  def times(a: Long, b: Long): Long = (a * b) % mod

  def fact(n: Long, res: Long = 1): Long = {
    if (n == 0) res else fact(n-1, times(res, n))
  }

  if ((n-m).abs > 1) {
    println(0)
  } else if (n == m) {
    val f = fact(n)
    println(times(2, times(f, f)))
  } else {
    val f = fact(n.min(m))
    println(times(f, times(f, n.max(m))))
  }
}
