#include <bits/stdc++.h>
using namespace std;
int exponentialinlog(long long x, unsigned int y, int p) {
  int res = 1;
  x = x % p;
  if (x == 0) {
    return 0;
  }
  while (y > 0) {
    if (y & 1) {
      res = (res * x) % p;
    }
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int prime_num(int n) {
  for (int i = 2; i < n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
int next_prime(int n) {
  int i = n + 1;
  while (!prime_num(i)) {
    i++;
  }
  return i;
}
void solve() {
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  map<int, int> m;
  for (int i = 1; i <= n; i++) {
    m[a[i]]++;
  }
  int flag = 0;
  int element = 0;
  for (auto it : m) {
    if (it.second == 1) {
      element = it.first;
      flag = 1;
      break;
    }
  }
  int ans = 0;
  if (!flag) {
    cout << "-1"
         << "\n";
    return;
  } else {
    for (int i = 1; i <= n; i++) {
      if (a[i] == element) {
        ans = i;
        break;
      }
    }
  }
  cout << ans << "\n";
  return;
}
int factorial(long long int n) {
  long long int fact = 1;
  for (int i = 1; i <= n; i++) {
    fact = fact * i;
  }
  return fact % 1000000007;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int a, b;
  cin >> a >> b;
  cout << factorial(min(a, b));
}
