# /usr/bin/python

# -*- coding: utf-8 -*-

import math







D = 10**9+7



def main():

  NM = sorted(list(map(int, input().split())))

  if NM[1]-NM[0] > 1:

    return 0

  elif NM[0]==NM[1]:

    ret = 2*(math.factorial(NM[0])**2) % D

    return ret

  else:

    ret = math.factorial(NM[0])*math.factorial(NM[1]) % D

    return ret



if __name__ == "__main__":

  print((main()))
# /usr/bin/python

# -*- coding: utf-8 -*-

import math







D = 10**9+7

def fact(n):

  ret = 1

  for i in range(1,n+1):

    ret = (ret*i) % D

  return ret





def main():

  NM = sorted(list(map(int, input().split())))

  n,m = [fact(NM[0]), fact(NM[1])]

  if NM[0]==NM[1]:

    return (n*m*2) % D

  elif NM[0]+1==NM[1]:

    return (n*m) % D

  else:

    return 0



if __name__ == "__main__":

  print((main()))
# /usr/bin/python
# -*- coding: utf-8 -*-
import math

D = 10**9 + 7


def main():
    NM = sorted(list(map(int, input().split())))
    if NM[1] - NM[0] > 1:
        return 0
    elif NM[0] == NM[1]:
        ret = 2 * (math.factorial(NM[0]) ** 2) % D
        return ret
    else:
        ret = math.factorial(NM[0]) * math.factorial(NM[1]) % D
        return ret


if __name__ == "__main__":
    print((main()))

# /usr/bin/python
# -*- coding: utf-8 -*-
import math

D = 10**9 + 7


def fact(n):
    ret = 1
    for i in range(1, n + 1):
        ret = (ret * i) % D
    return ret


def main():
    NM = sorted(list(map(int, input().split())))
    n, m = [fact(NM[0]), fact(NM[1])]
    if NM[0] == NM[1]:
        return (n * m * 2) % D
    elif NM[0] + 1 == NM[1]:
        return (n * m) % D
    else:
        return 0


if __name__ == "__main__":
    print((main()))

+def fact(n): +    ret = 1 +    for i in range(1, n + 1): +        ret = (ret * i) % D +    return ret + + -    if NM[1] - NM[0] > 1: +    n, m = [fact(NM[0]), fact(NM[1])] +    if NM[0] == NM[1]: +        return (n * m * 2) % D +    elif NM[0] + 1 == NM[1]: +        return (n * m) % D +    else: -    elif NM[0] == NM[1]: -        ret = 2 * (math.factorial(NM[0]) ** 2) % D -        return ret -    else: -        ret = math.factorial(NM[0]) * math.factorial(NM[1]) % D -        return ret