program main
  implicit none
  integer(8) :: m = 10 ** 9 + 7
  integer(8) :: n, k, i, g, res
  integer(8), allocatable :: s(:), t(:)
  read *, n, k
  allocate (s(k), t(k))
  do i = 1, k
    t(i) = get_t(i)
  end do
  s(:) = t(:)
  do g = k, 1, -1
    do i = 2, k / g
      s(g) = s(g) - s(i * g)
      s(g) = modulo(s(g), m)
    end do
  end do
  res = 0
  do g = 1, k
    res = res + g * s(g)
    res = modulo(res, m)
  end do
  print "(i0)", res

  contains

  integer(8) function get_t(f)
    integer(8), intent(in) :: f
    integer(8) :: ng
    ng = k / f
    get_t = pow(ng, n)
  end function get_t

  recursive function pow(n, p) result(res)
    integer(8), intent(in) :: n, p
    integer(8) :: res
    if (p == 0) then
      res = 1
    else if (modulo(p, 2_8) == 0) then
      res = modulo(pow(n, p / 2) ** 2, m)
    else
      res = modulo(pow(n, p - 1) * n, m)
    end if
  end function pow
end program main
