from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline N,M = map(int,input().split()) mod = 10**9 + 7 class combination(): def __init__(self,N,p): self.fact = [1, 1] # fact[n] = (n! mod p) self.factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p) self.inv = [0, 1] # factinv 計算用 self.p = p for i in range(2, N + 1): self.fact.append((self.fact[-1] * i) % p) self.inv.append((-self.inv[p % i] * (p // i)) % p) self.factinv.append((self.factinv[-1] * self.inv[-1]) % p) def cmb(self,n, r): if (r < 0) or (n < r): return 0 r = min(r, n - r) return self.fact[n] * self.factinv[r] * self.factinv[n-r] % self.p C = combination(M+1,mod) if N>M: print(1) exit() if N==1: print(1) exit() ans = 1 cnt = 1 while M - N*cnt >=0 : ans += C.cmb(M-cnt*(N-1),cnt) # print(cnt,C.cmb(M-cnt*(N-1),cnt)) ans %= mod cnt += 1 print(ans)