CSES - Shared codeLink to this code: https://cses.fi/paste/06074e54d99c3bb248646e/
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
#define IOS ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);

typedef pair<int,int>pr;
#define all(i)     i.begin() , i.end()
#define ft     first
#define sn     second
#define pb push_back

const int mod = 1e9+7;
#define en "\n"
#define dbg cout<<"rony\n";

#define MAXN 3000010
ll fact[MAXN];

ll Bigmod(ll a,ll n)
{
  ll rs = 1;
  while(n)
  {
    if(n%2 == 0){
      n /= 2;
      a = (a * a)%mod;
    }
    else{
      n--;
      rs = (rs * a)%mod;
    }
  }
  return rs;
}
ll nCr(ll n,ll r)
{
   fact[0] = 1;
   for(int i = 1;i <= n;i++)
   {
      fact[i] = fact[i-1] * i;
      fact[i] %= mod;
   }

   ll an = fact[n];
   an = an * (Bigmod(fact[r],mod - 2));
   an %= mod;
   an = an * (Bigmod(fact[n - r],mod - 2));
   an %= mod;
   return an;

}
void solve()
{
  int n,m;
  cin >> n >> m;

  int r = m;

  if(n-1 <= m) 
    r = n-1;

  cout<<nCr(n + m - 1, r)<<en;
  
} 

int main()
{
    IOS;
    int t;
  // cin >> t;
  t = 1;
    while ( t-- )
    {

        solve();
    }
    return 0;
}