#include <bits/stdc++.h>
using namespace std;

const int64_t mod=1e9+7;
int64_t a,b,fac[100005];

int main()
{
    cin>>a>>b;
    fac[0]=1;
    for(int64_t i=1;i<=1e5;i++)
        fac[i]=fac[i-1]*i%mod;
    if(abs(a-b)>=2)
        cout<<0;
    else
    if(a==b)
        cout<<2LL*fac[a]*fac[b]%mod;
    else
        cout<<fac[a]*fac[b]%mod;
}
