RETO7 - El Hotel con Habitaciones Infinitas

HaluaRuti city has a strange hotel with infinite rooms. The groups that come to the hotel follow the following rules:

  • At the same time, only members of a group can rent the hotel.
  • Each group arrives in the morning one day and out the evening of another day.
  • Another group arrives in the morning after a group left the hotel.
  • A very important feature of a group that arrives is to have a member more than the previous group unless it is the first group. You will have the number of members of the original group.
  • A group with n members stay for n days in the hotel. For example, if a group of four members arrive on August 1 in the morning, this will leave the hotel on August 4 night and the next group of five members arrive on Aug. 5 in the morning and go on 5 days and so on. Given an initial group size you should find the size of the group is in the hotel on a specific day.

Spanish version

Input

The input contains integers S (1 <= S <= 10000) and D (1 <= D <= 1015) in each line. S denotes the initial size of the group and D denotes the day for which you must find the size of the group at the hotel, D-th day (starting from 1). All integers input and output are lower than 1015. A group size S means that on the first day a group of S members came to the hotel and stay for S days, then come a group of S + 1 members according to the rules described above.

Output

For each line of input, print in a line the size of the group at the hotel in the D-th day.

Example

Input:
1 6
3 10
3 14

Output:
3
5
6

Added by:MaratónAFDM
Date:2016-10-07
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:MAWK BC C NCSHARP CSHARP C++ 4.3.2 CPP14 COFFEE DART FORTH JAVA JS-RHINO JULIA KTLN NODEJS OBJC OCT PHP PROLOG PYTHON PYPY3 PYTHON3 R RACKET SQLITE SWIFT UNLAMBDA

hide comments
2017-09-29 15:48:02
I got the correct output but when i submitted i got wrong answer. Can anyone help me?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.