시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 7 3 1 33.333%

## 문제

A smallest different sequence (SDS) is a sequence of positive integers created as follows: A1 = r ≥ 1. For n > 1, An = An−1 + d, where d is the smallest positive integer not yet appearing as a value in the sequence or as a difference between two values already in the sequence. For example, if A1 = 1, then since 2 is the smallest number not in our sequence so far, A2 = A1 + 2 = 3. Likewise A3 = 7, since 1, 2 and 3 are already accounted for, either as values in the sequence, or as a difference between two values. Continuing, we have 1, 2, 3, 4, 6, and 7 accounted for, leaving 5 as our next smallest difference; thus A4 = 12. The next few values in this SDS are 20, 30, 44, 59, 75, 96, . . . For a positive integer m, you are to determine where in the SDS m first appears, either as a value in the SDS or as a difference between two values in the SDS. In the above SDS, 12, 5, 9 and 11 first appear in step 4.

## 입력

Input consists of a single line containing two positive integers A1 m (1 ≤ r ≤ 100, 1 ≤ m ≤ 200 000 000).

## 출력

Display the smallest value n such that the sequence A1, . . . , An either contains m as a value in the sequence or as a difference between two values in the sequence. All answers will be ≤ 10 000.

## 예제 입력 1

1 5


## 예제 출력 1

4


## 예제 입력 2

1 12


## 예제 출력 2

4


## 예제 입력 3

5 1


## 예제 출력 3

2