{-# LANGUAGE MultiWayIf #-}

import Data.List
import Control.Applicative

main :: IO ()
main = do
  [n,m] <- read <$> getLine :: IO [Int]
  let ma = max n m
      di = abs (n-m)
  print
   $ if di >= 2 then 0
     else prod [ma..1]
           `mult` if di == 1 then ma+1 else 2 
  

modulus :: Int
modulus = 10^9 + 7

mult :: Int -> Int -> Int
mult x y = (x * y) `mod` modulus

prod :: [Int] -> Int
prod = foldl' mult 1