import           Control.Monad
import qualified Data.Array.IO               as IO
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

-- compulte a^n `mod` p
modpow :: Int -> Int -> Int -> Int
modpow a n p =
  let modpow' a n res | n == 0    = res
                      | otherwise =
                          modpow' (a*a`mod`p)
                                  (n `shiftR` 1)
                                  (if (n .&. 1) == 1 then res * a `mod` p else res)
  in modpow' a n 1

main = do
  [n, k] <- getIntList

  d <- VM.new (k+1)
  VM.set d (0::Int)

  let p = 10^9 + 7 :: Int

  forM_ [k,(k-1)..1] $ \x -> do
    let c = modpow (k `div` x) n p
    VM.write d x c
    when (k `div` x >= 2) $
      forM_ [2..(k `div` x)] $ \i -> do
        t <- VM.read d (i*x)
        c' <- VM.read d x
        VM.write d x ((c' - t) `mod` p)

  d' <- V.freeze d

  VM.write d 0 0
  forM_ [1..k] $ \i -> do
    t <- VM.read d 0
    VM.write d 0 ((i * (d' V.! i) `mod` p + t) `mod` p)

  ans <- VM.read d 0
  print ans