program test
implicit none
integer,parameter :: big = 10000
integer :: i,j,k,n,a,b,c,mat(big,big)=0,res=0,ans(big)=0,final=0

read(*,*) n,k

do a=1,k
  do b=1,k
      res = gcd(a,b)
      mat(res,a) = mat(res,a) + 1
  enddo
enddo

do i=1,k
  ans(i) = 1
enddo


do i=1,n-1
  ans(1:k) = matmul(mat(1:k,1:k),ans(1:k))
  do j=1,k
    ans(j) = mod(ans(j),10**9+7)
  enddo
enddo

do i=1,k
  final = mod(final + i*ans(i),10**9+7)
enddo

write(*,*) final

contains
integer function gcd(a,b)
  implicit none
  integer, intent(in) :: a,b
  integer :: l,m,n

  m = a
  n = b

  do
    l = mod(m,n)
    if (l == 0) exit
    m = n
    n = l
  end do

  gcd = n

  return
end function gcd

end program