N,M = map(int,input().split()) mod = 10**9+7 for i in range(1,M+1): Q = N//i r = N%i if r: res = pow(Q,i-r,mod) * pow(Q+1,r,mod) else: if i>=2: res = pow(Q,i-2,mod) * (Q**2-1) else: res = N print(res%mod)