#include <bits/stdc++.h>
//#include<iostream>
using namespace std;
typedef long long ll;

class GF {
public:
    ll x;
    static ll p;

    GF(ll x);
    GF &operator=(const GF &a);
    static bool is_prime(const ll n);
    static ll powmod(ll a, ll x, ll p);
    static void set_prime(ll p);
    static ll get_prime();
    ll get();

    GF operator-() const;
    GF& operator+=(const GF& a);
    GF& operator-=(const GF& a);
    GF& operator*=(const  GF& a);
    GF operator+(const GF& a) const;
    GF operator-(const GF& a) const;
    GF operator*(const GF& a) const;
    GF pow(ll t) const;
    // for prime mod
    GF inv() const;
    GF& operator/=(const GF& a);
    GF operator/(const GF& a) const;

    bool operator==(const GF &a) const;
    inline bool operator!=(const GF &a) const;
    bool operator<(const GF &a) const;
    inline bool operator>=(const GF &a) const;
    bool operator>(const GF &a) const;
    inline bool operator<=(const GF &a) const;

    friend ostream& operator<<(ostream& os, const GF& m){
        os << m.x;
        return os;
    }
};

ll GF::p = 11;
GF::GF(ll x=0) : x((x%p+p)%p) {}
ll GF::powmod(ll a, ll x, ll p){
    ll res=1;
    while(x>0){
        if(x%2 == 1){
            res = (res * a) % p;
        }
        a = (a*a)%p;
        x >>= 1;
    }
    return res;
}
bool GF::is_prime(ll n){
    if(n == 2) return(true);
    if(n == 1 || (n&1) == 0) return (false);

    random_device rd;
    mt19937_64 mt(rd());
    ll s=1;
    ll d=n;
    int challenge = 10;
    do{
        d >>= 1;
    }while((d&1) == 0);

    for(int i=0;i<challenge;i++){
        ll a = 1 + mt() % (n-1);
        ll t = d;
        ll y = powmod(a,t,n);
        //cout << a << " " << t << " " << y << endl;
        while(t != n-1 && y != 1 && y != n-1){
            y = powmod(y,2,n);
            t <<= 1;
        }
        if(y != n-1 && (t&1) == 0) return false;
    }
    
    return(true);
}

ll GF::get_prime(){
    return GF::p;
}
void GF::set_prime(ll n){
    assert(GF::is_prime(n));
    GF::p = n;
}
ll GF::get(){
    return x;
}
GF& GF::operator=(const GF &a){
    x = a.x;
    return *this;
}
GF GF::operator-() const { 
    return GF(-x);
}
GF& GF::operator+=(const GF& a) {
    ll prime = GF::p;
    //if ((x += a.x) >= prime) x -= prime;
    (x = x + a.x) %= prime;
    return *this;
}
GF& GF::operator-=(const GF& a) {
    ll prime = GF::p;
    //if ((x += prime-a.x) >= prime) x -= prime;
    (x = x-a.x+prime) %= prime;
    return *this;
}
GF& GF::operator*=(const  GF& a) {
    ll prime = GF::p;
    (x *= a.x) %= prime;
    return *this;
}
GF GF::operator+(const GF& a) const {
    GF res(*this);
    return res+=a;
}
GF GF::operator-(const GF& a) const {
    GF res(*this);
    return res-=a;
}
GF GF::operator*(const GF& a) const {
    GF res(*this);
    return res*=a;
}
GF GF::pow(ll t) const {
    if (!t) return 1;
    GF a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
}

// for prime mod
GF GF::inv() const {
    ll prime = GF::p;
    return pow(p-2);
}
GF& GF::operator/=(const GF& a) {
    return (*this) *= a.inv();
}
GF GF::operator/(const GF& a) const {
    GF res(*this);
    return res/=a;
}
bool GF::operator==(const GF &a) const {
    return x == a.x;
}
bool GF::operator!=(const GF &a) const {
    return !(*this == a);
}
bool GF::operator<(const GF &a) const {
    return x < a.x;
}
bool GF::operator>=(const GF &a) const {
    return !(*this < a);
}
bool GF::operator>(const GF &a) const {
    return x > a.x;
}
bool GF::operator<=(const GF &a) const {
    return !(*this > a);
}

GF factorial(GF a){
  GF res(1);
  while(a>0){
    res *= a;
    a -= 1;
    //cout << res << endl;
  }
  return res;
}

int main(){
    GF::set_prime(1e9+7);
    ll tmp1,tmp2;
    cin >> tmp1 >> tmp2;
    if(abs(tmp1-tmp2) > 1){
      cout << 0 << endl;
      return(0);
    }
    GF a(tmp1),b(tmp2),ans;
    if(tmp1-tmp2 == 1){
        ans = factorial(a)*factorial(b);
    }else if(tmp1 - tmp2 == -1){
        ans = factorial(b)*factorial(a);        
    }else{
        ans = factorial(a)*factorial(b);
        ans *= 2;
    }      

    cout << ans << endl;

    return(0);
}

Measured memory_bytes: 3636