import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Data.List
import Data.Ord
import Control.Monad


r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

main :: IO ()
main = do
    [n,m] <- r'
    print $ if abs (n-m) > 1 then 0 else (if n==m then (*2) else id) (fact n * fact m)

fact :: Int -> Mint
fact n = product $ map fromIntegral [1..n]




mdl = 1000000007

(^%) :: Int -> Int -> Int
b ^% e = powAux (b `rem` mdl) e 1 `mod` mdl
    where 
        powAux _ 0 ac = ac
        powAux b e ac = powAux (b*b `rem` mdl) (e `quot` 2)
            (if odd e then b*ac `rem` mdl else ac)

(+%), (-%), (*%), (/%) :: Int -> Int -> Int
a +% b = (a + b) `rem` mdl
a -% b = (a - b) `mod` mdl
a *% b = (a * b) `rem` mdl
a /% b = (a * invMod b) `mod` mdl
    where   invMod :: Int -> Int
            invMod = (^% (mdl-2))

newtype Mint = M Int deriving Eq
instance Num Mint where
    M a + M b = M (a +% b)
    M a * M b = M (a *% b)
    M a - M b = M (a -% b)
    abs = id
    signum (M 0) = 0
    signum _ = 1
    fromInteger = M.(`mod`mdl).fromInteger
instance Show Mint where
    show (M a) = show a