#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, long long);
int scanf(char *, long long *, long long *);
int main() {
  long long s, d;
  while (scanf("%lld %lld", &s, &d) == 2) {
    while (d > 0) {
      d -= s;
      s++;
    }
    printf("%lld\n", s - 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <scanf@plt>
cmp    $0x2,%eax
jne    1195 <main+0x75>
jmp    1151 <main+0x31>
cmpq   $0x0,-0x18(%rbp)
jle    117c <main+0x5c>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1151 <main+0x31>
mov    -0x10(%rbp),%rsi
sub    $0x1,%rsi
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xece(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1040 <scanf@plt>
cmp    $0x2,%eax
jne    11a8 <main+0x88>
lea    0xebd(%rip),%r14
lea    0xeac(%rip),%r15
lea    0x10(%rsp),%r12
lea    0x8(%rsp),%rbx
jmp    117f <main+0x5f>
add    $0xffffffffffffffff,%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <scanf@plt>
cmp    $0x2,%eax
jne    11a8 <main+0x88>
mov    0x8(%rsp),%rax
mov    0x10(%rsp),%rsi
test   %rax,%rax
jle    1160 <main+0x40>
xchg   %ax,%ax
mov    %rsi,%rcx
add    $0x1,%rsi
sub    %rcx,%rax
jg     1190 <main+0x70>
mov    %rax,0x8(%rsp)
mov    %rsi,0x10(%rsp)
jmp    1160 <main+0x40>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%lld %lld\00"
@.str.1 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
br label %4
4: ; preds = %17, %0
%5 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64* %2, i64* %3)
%6 = icmp eq i32 %5, 2
br i1 %6, label %7, label %21
7: ; preds = %4
br label %8
8: ; preds = %11, %7
%9 = load i64, i64* %3
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = load i64, i64* %2
%13 = load i64, i64* %3
%14 = sub nsw i64 %13, %12
store i64 %14, i64* %3
%15 = load i64, i64* %2
%16 = add nsw i64 %15, 1
store i64 %16, i64* %2
br label %8
17: ; preds = %8
%18 = load i64, i64* %2
%19 = sub nsw i64 %18, 1
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %19)
br label %4
21: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"%lld %lld\00"
@.str.1 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64* %1, i64* %2)
%6 = icmp eq i32 %5, 2
br i1 %6, label %7, label %24
7: ; preds = %0, %18
%8 = load i64, i64* %2
%9 = load i64, i64* %1
%10 = icmp sgt i64 %8, 0
br i1 %10, label %11, label %18
11: ; preds = %7, %11
%12 = phi i64 [ %14, %11 ], [ %8, %7 ]
%13 = phi i64 [ %15, %11 ], [ %9, %7 ]
%14 = sub nsw i64 %12, %13
%15 = add nsw i64 %13, 1
%16 = icmp sgt i64 %14, 0
br i1 %16, label %11, label %17
17: ; preds = %11
store i64 %14, i64* %2
store i64 %15, i64* %1
br label %18
18: ; preds = %17, %7
%19 = phi i64 [ %15, %17 ], [ %9, %7 ]
%20 = add nsw i64 %19, -1
%21 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %20)
%22 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64* %1, i64* %2)
%23 = icmp eq i32 %22, 2
br i1 %23, label %7, label %24
24: ; preds = %18, %0
ret i32 0
}