open System

let N,K = 
    let t = Console.ReadLine().Split() 
            |> Array.map(int)
    t.[0],t.[1]
                
let f b =
    //e [0,1,2,..,b-1]
    //r [0,1,2,..,r]
    //pb + r (0 <= t < b)
    let e = N % b
    let p = N / b
    let r =  
        if   K = 0  then e
        elif e >= K then e - K + 1
        else             0   
    (b - K) * p + r                 
    
[K+1..N]
|> List.map(fun x -> f x)
|> List.sum
|> printfn "%i" 
    