import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

enum MOD = 1_000_000_007;

struct Number {
    long x;
    this(long x) {
        this.x = (x % MOD + MOD) % MOD;
    }

    Number opBinary(string op)(long x) {
        return Number(mixin("this.x"~op~"x"));
    }

    Number opBinary(string op)(Number n) {
        return Number(mixin("this.x"~op~"n.x"));
    }
}

void main() {
    auto tmp = readln.split.to!(long[]);

    Number fact(Number n) {
        if (n.x == 0) return Number(1);
        return n * fact(n-1);
    }
    auto solve() {
        if (tmp[0] > tmp[1]+1) return Number(0);
        if (tmp[1] > tmp[0]+1) return Number(0);
        if (tmp[0] == tmp[1]) return fact(Number(tmp[0])) * fact(Number(tmp[1])) * 2;
        return fact(Number(tmp[0])) * fact(Number(tmp[1]));
    }
    solve().x.writeln;
}

