Under construction

Still being built. Things may change

Octopus

Time limit1sMemory limit1024 MB

Summary
Starting from N vertices with no edges, find the most vertices that can each have exactly K incident edges in a simple undirected graph.
Level

Medium4 of 10

Topics
Math, Graph
Solved
No attempts yet

Problem

Graph GG starts with NN vertices and no edges. You may add undirected edges between two distinct vertices any number of times, but you cannot add a duplicate edge. Given NN, find the maximum number of octopus vertices that can be made by adding edges.

  • A vertex VV in a graph is called an octopus if exactly KK edges are connected to it.

Input

The first line contains NN and KK, separated by a space.

Output

On the first line, print the maximum number of octopus vertices that can be made by adding edges.

Constraints

1≤N,K≤100 0001 \le N, K \le 100\,000

Examples2

  1. Example 1

    Input
    4 3
    
    Expected output
    4
    
  2. Example 2

    Input
    5 5
    
    Expected output
    0