Vasya and the Apartments
Time limit1sMemory limit1024 MB
Given N apartments numbered 1 to N and a target sum S, find the fewest plates to swap for new natural numbers so the total becomes S.
- Level
Medium5 of 10
- Topics
- Math, Binary search
- Solved
- No attempts yet
Problem
Vasya is a fifth grader who lives in a building with apartments in total. The apartments are numbered from 1 to , and a plate with the apartment number is hung beside each one. Vasya wants to replace some of the plates so that the sum of the apartment numbers equals .
At the store, Vasya can buy plates with any natural numbers. Find the minimum number of plates Vasya must buy to carry out his sneaky plan.
Input
The only line contains two integers and (, ).
Output
Print one number: the minimum number of plates Vasya must buy to get the sum . It is guaranteed that this can be done.