mod = 10 ** 9 + 7
class combinatorics:
    def __init__(self, n):
        self.n = n
        self.fa = [1] * (self.n * 2 + 1)
        self.fi = [1] * (self.n * 2 + 1)
        for i in range(1, self.n * 2 + 1):
            self.fa[i] = self.fa[i - 1] * i % mod
        self.fi[-1] = pow(self.fa[-1], mod - 2, mod)
        for i in range(self.n * 2, 0, -1):
            self.fi[i - 1] = self.fi[i] * i % mod
    def comb(self, n, r):
        if n < r:return 0
        if n < 0 or r < 0:return 0
        return self.fa[n] * self.fi[r] % mod * self.fi[n - r] % mod
    def perm(self, n, r):
        if n < r:return 0
        if n < 0 or r < 0:return 0
        return self.fa[n] * self.fi[n - r] % mod
    def combr(self, n, r):
        if n == r == 0:return 1
        return self.comb(n + r - 1, r)

#拡張Euclidの互除法
def extgcd(a, b, d = 0):
    g = a
    if b == 0:
        x, y = 1, 0
    else:
        x, y, g = extgcd(b, a % b)
        x, y = y, x - a // b * y
    return x, y, g

#mod p における逆元
def invmod(a, p):
    x, y, g = extgcd(a, p)
    x %= p
    return x

n, m = map(int, input().split())
if n == 1:exit(print(1))
ans = 0
C = combinatorics(m)
for i in range(m // n + 1):
    ans += C.comb(m - i * (n - 1), i)
    ans %= mod
print(ans)