{-# LANGUAGE BangPatterns #-}

import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Arrow

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine




main = do
    [n,k] <- r'
    print $ sum $ map (M .(solveExact n)) [k..n+1]

lg x = x * (x + 1) `div` 2

solveExact n k =
    let l = lg (k-1)
        m = lg n - lg (n-k)
    in  m - (l - 1)

---------------------
-- #   Modulus   # --
---------------------

mdl = 1000000007

(^%) :: Int -> Int -> Int
b ^% e = powAux (b `rem` mdl) e 1 `mod` mdl
    where 
        powAux _ 0 !ac = ac
        powAux b e !ac = powAux (b*b `rem` mdl) (e `quot` 2)
            (if odd e then b*ac `rem` mdl else ac)

(+%), (-%), (*%), (/%) :: Int -> Int -> Int
a +% b = (a + b) `rem` mdl
a -% b = (a - b) `mod` mdl
a *% b = (a * b) `rem` mdl
a /% b = (a * invMod b) `mod` mdl
    where   invMod :: Int -> Int
            invMod = (^% (mdl-2))

newtype Mint = M Int deriving Eq
instance Show Mint where
    show (M i) = show i 
instance Num Mint where
    M a + M b = M (a +% b)
    M a * M b = M (a *% b)
    M a - M b = M (a -% b)
    abs = id
    signum (M 0) = 0
    signum _ = 1
    fromInteger = M.(`mod`mdl).fromInteger