#include <bits/stdc++.h>
#define int ll
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);i
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin); i != (end); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'

using namespace std;
typedef long long ll;
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int X10 = 1024, X11 = 2048, X12 = 4096, X13 = 8196, X14 = 16392, X15 = 32786, X16 = 65536, X17 = 131072, X18 = 262144, X19 = 524288, X20 = 1048576;

const int MOD = (int) (1e9 + 7);

template<typename FI>
void parted_rotate(FI first1, FI last1, FI first2, FI last2)
{
    if(first1 == last1 || first2 == last2) return;
    FI next = first2;
    while (first1 != next) {
        std::iter_swap(first1++, next++);
        if(first1 == last1) first1 = first2;
        if (next == last2) {
            next = first2;
        } else if (first1 == first2) {
            first2 = next;
        }
    }
}

template<typename BI>
bool next_combination_imp(BI first1, BI last1, BI first2, BI last2)
{
    if(first1 == last1 || first2 == last2) return false;
    auto target = last1; --target;
    auto last_elem = last2; --last_elem;
    // find right-most incrementable element: target
    while(target != first1 && !(*target < *last_elem)) --target;
    if(target == first1 && !(*target < *last_elem)) {
        parted_rotate(first1, last1, first2, last2);
        return false;
    }
    // find the next value to be incremented: *next
    auto next = first2;
    while(!(*target < *next)) ++next;
    std::iter_swap(target++, next++);
    parted_rotate(target, last1, next, last2);
    return true;
}

// INVARIANT: is_sorted(first, mid) && is_sorted(mid, last)
template<typename BI>
inline bool next_combination(BI first, BI mid, BI last)
{
    return next_combination_imp(first, mid, mid, last);
}

// INVARIANT: is_sorted(first, mid) && is_sorted(mid, last)
template<typename BI>
inline bool prev_combination(BI first, BI mid, BI last)
{
    return next_combination_imp(mid, last, first, mid);
}

bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;

    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;

    return true;
}


const int MX = 200000 + 5;
int _FAC[MX+1];
int power(int x, int y, int p)
{
    int res = 1;

    x = x % p;

    while (y)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}

int C(int n, int r, int p)
{
    if (r==0)
        return 1;
    if(r > n || r < 0 || n<0) return  0;
    return (_FAC[n]* modInverse(_FAC[r], p) % p *
            modInverse(_FAC[n-r], p) % p) % p;
}

void init(){
    _FAC[0] = 1;
    for (int i=1 ; i<=MX; i++)
        _FAC[i] = _FAC[i-1]*i%MOD;
}


map<int, int> factorize(long long n)
{
    map<int, int> factors;
    int count = 0;

    while (!(n % 2)) {
        n >>= 1;
        count++;
    }

    if(count)factors[2] = count;

    for (long long i = 3; i <= sqrt(n); i += 2) {
        count = 0;
        while (n % i == 0) {
            count++;
            n = n / i;
        }
        if (count)
            factors[i] = count;
    }

    if (n > 2)
        factors[n] = 1;
    return factors;
}

int A[100000+5];
void _() {
    init();
    int n, m;
    cin >> n >> m;
    if(abs(n-m)>1)cout << 0;
    else {
        cout << _FAC[n] * _FAC[m] *(2-abs(n-m)) %MOD;
    }



}

#undef int
int main() {
#ifdef Debug
    freopen("/home/hiroo/Desktop/competitive-programming/IO/Input.txt", "r", stdin);
    freopen("/home/hiroo/Desktop/competitive-programming/IO/Output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}




Measured memory_bytes: 1792