def doit():
    n, m = map(int, raw_input().split())
    if n ==1:
        print 1
        return

    if m > n:
        m = n

    left = n - m

    l = m
    r = n

    while l <= r :
        mid = (l+r)/2
        if left > mid*(mid+1)/2 - m*(m+1)/2 - (mid-m) * m:
            l = mid + 1
        else:
            r = mid -1

    print l

doit()

n, m = [int(i) for i in input().split()]

if m >= n:
    print(n)
else:
    l = 1
    r = n

    while (l != r):
        cur = (l + r) // 2
        if (1 + cur) * cur // 2 >= (n - m):
            r = cur
        else:
            l = cur + 1

    print(m + l)

from math import *
from collections import *
from random import *
from decimal import Decimal
from bisect import *
import sys
input=sys.stdin.readline
def lis():
    return list(map(int,input().split()))
def ma():
    return map(int,input().split())
def inp():
    return int(input())
def fk(a,s,k):
    b=[]
    for i in range(len(a)):
        b.append(a[i]+(i+1)*k)
    b.sort()
    return sum(b[:k])
n,m=ma()
if(m>=n):
    print(n)
    exit(0)
re=m
c=(-1+(Decimal(1+8*(n-m)))**(Decimal(0.5)))/2
c=ceil(c)
print(c+re)

def discards(m,k):
	alls = (m*(m+1))//2
	if(k>m):
		return alls
	k=m-k
	k=(k*(k+1))//2
	return alls-k

def solve(n, m, k):
	cantake = (k*(k+1))//2
	grain = n+m*k
	grain = grain-discards(m,k)
	return grain<=cantake

def fast(n,m):
	l=1
	r=n
	res=n+1
	while(l<=r):
		if(l==r):
			if(solve(n,m,l)):
				res=min(res,l)
			break

		mm=(l+r)//2;
		if(solve(n,m,mm)):
			r=mm-1
			res=min(res,mm)
		else:
			l=mm+1

	return res

n,m = map(int,input().split())
print(fast(n,m))

import sys

cases = False

def c2(n):
    return n * (n+1) // 2

def get():
    return list(map(int, input().split()))

def bits(n: int):
    return list(bin(n)).count('1')

def main(test_case = False):
    n = int(input()) if test_case else 1
    for _ in range(n):
        test()

def flush():
    sys.stdout.flush()

def parr(arr):
    print(*arr, sep=' ')

def gcd(a, b):
    while b:
        if b % a == 0:
            break
        tmp = a
        a = b % a
        b = tmp
    return a

def check(n, m, k):
    t = k - m - 1
    if t < 0: return False
    return n <= k + t * (t+1) // 2

def test():
    n, m = get()
    left = 1
    right = n
    ans = right

    while left <= right:
        mid = (left + right) // 2
        if check(n, m, mid):
            ans = min(ans, mid)
            right = mid - 1
        else:
            left = mid + 1

    print(ans)

main(cases)

import math

n,m = map(int,raw_input().split())

if m >= n:
    print n
    exit()

s = n - m

x = (-1.0 + math.sqrt(1 + 8 * s))/2
x = int(x)
if x * (x+1) / 2 < s: x = x + 1

print x + m

n, m = map(int, raw_input().split())
if m > n:
    print n
    exit(0)
lo, hi = 0, 2*10**9
while lo < hi:
    mid = (lo + hi + 1) // 2
    rem = (mid * (mid - 1)) // 2
    if n <= m + rem:
        hi = mid - 1
    else:
        lo = mid
print lo + m

def func(l):
    return l*m+n - (m+1+l)*(m+2+l)//2 + (m+1)*m//2
from math import ceil
n, m = [int(x) for x in input().split()]
if m >= n:
    print(n)
else:
    l = ceil((-3 + (9-8*(m+1-n))**0.5)/2)
    for i in range(l-1, l+10):
        if func(i) <= 0:
            print(m+1+i)
            break

from sys import stdin, stdout

n, m = map(int, stdin.readline().rstrip().split())

def triangle(x):
    return x*(x+1)//2

if n<=m:
    print(n)
else:
    target=n-m # Want to find the triangle number which is greater than the target
    minNum=0
    maxNum=int(1e10)
    finished=False
    while not finished:
        newNum = (minNum+maxNum)//2
        if triangle(newNum)<target and triangle(newNum+1)>=target:
            finished=True
        elif triangle(newNum)<target:
            minNum=newNum
        elif triangle(newNum)>=target and triangle(newNum-1)<target:
            finished=True
            newNum-=1
        else:
            maxNum=newNum
    print(m+newNum+1)

n, m = map(int, input().split())
if (n <= m) :
	print(n)
else:
	l = m
	r = n
	while (r - l > 1):
		mid = (l + r) // 2

		if (0 >= n - (mid - m - 1) * (mid - m) // 2 - mid):
			r = mid
		else:
			l = mid

	print(r)

import decimal

n,m=map(int,input().split())

if(n<=m):
    print(n)
else:
    decimal.getcontext().rounding=decimal.ROUND_CEILING;
    decimal.getcontext().prec=100;
    print(((decimal.Decimal(1+8*(n-m)).sqrt()-1)/2+m).to_integral_exact())

import decimal

n,m=map(int,input().split())

if(n<=m):
    print(n)
else:
    decimal.getcontext().rounding=decimal.ROUND_CEILING;
    decimal.getcontext().prec=10000;
    print(((decimal.Decimal(1+8*(n-m)).sqrt()-1)/2+m).to_integral_exact())

n, m = map(int, input().split())
if m >= n:
    print(n)
else:
    n -= m
    l, r = 0, n
    while l < r:
        mid = (l + r) // 2
        if (1 + mid) * mid // 2 >= n:
            r = mid
        else:
            l = mid + 1
    print(l + m)

def check(mid, n, m):
    k = min(n, m + 1)
    return n + (mid - k) * m - (2 * k + mid - k) * (mid - k + 1) // 2 <= 0

n, m = map(int, input().split())
l = min(n, m)
r = n
while r - l > 1:
    mid = (l + r) // 2
    if check(mid, n, m):
        r = mid
    else:
        l = mid

for i in range(l, r + 1):
    if check(i, n, m):
        print(i)
        break

n, m = [int(x) for x in input().split()]

if n <= m:
    print(n)
else:
    left = int(0)
    right = int(1e10)

    while left < right:
        x = (left + right) // 2

        res = n + m*x - ((x + m + 1)*(x + m + 2) - m*(m + 1))//2

        if res <= 0:
            right = x;
        else:
            left = x + 1;

    print(left + m + 1)

capcity,fill=map(int,input().split())
if fill > capcity:
	print(capcity)
	exit()
last=0
num=capcity-fill
l,r = 1,num
while(l<=r):
	mid = l + (r-l)//2
	x=(mid*(mid+1))//2
	if(x>=num):
		last = mid
		r = mid - 1
	else:
		l = mid + 1
print(last+fill)

n, m = map(int, input().split())
l = 0
r = 10 ** 18 + 1
d = n - m
while r - l > 1:
    mi = (r + l) // 2
    if d > mi *(mi + 1) // 2:
        l = mi
    else:
        r = mi
if n > m:
    print(r + m)
else:
    print(n)

def f(n, m, da):
	if (da <= m):
		return n - da
	else:
		da -= m
		end_m = n - m
		return end_m - ((da * (da + 1)) // 2)

def main():
	n, m = map(int, input().split())
	if (f(n, m, 1) > 0):
		l = 1;
		r = 10**18
		while (l + 1 < r):
			me = (l + r ) // 2
			if (f(n,m,me) > 0):
				l = me
			else:
				r = me
		print(r)
	else:
		print(1)

main()

from math import *

n,m = [int(j) for j in input().split()]

if n <= m:
    print(n)
else:
    k= ceil((-1 + sqrt(1 + 8*(n-m)))/2)
    while (k*(k+1) >= 2 * (n - m)):
        k -= 1
    k += 1
    print(m + k)

def check(mid):
    global n, m
    cnt = n - ((mid - m) * (mid - m - 1) // 2)
    if mid >= cnt:
        return True
    else:
        return False

def binn():
    global n, m
    l = min(n, m)
    r = n + 1
    while (l + 1 < r):
        mid = (l + r) // 2
        if (check(mid)):
            r = mid
        else:
            l = mid

    print(min(n, r))

n, m = map(int, input().split())
binn()

def solution():
    n, m = map(int, input().split())
    ans = n
    lo, hi = m + 1, 10 ** 30
    while lo != hi:
        mid = ( lo + hi ) // 2
        if 2 * m + ( mid - m ) * ( mid - m + 1 ) < 2 * n:
            lo = mid + 1
        else:
            hi = mid
    ans = min(ans, lo)
    print(ans)

if __name__ == '__main__':
    solution()

n, m = map(int, input().split())
if n == 1:
  print(1)
elif m >= n - 1:
  print(n)
else:
  r = 1000000000000000000
  frm = m + 1
  l = frm
  while r - l > 1:
    mid = (l + r) // 2
    sum = (mid - frm + 1) * (mid - frm) // 2
    if n - sum - mid <= 0:
      r = mid
    else:
      l = mid
  sum = (l - frm) * (l - frm + 1) // 2
  if n - sum - l <= 0:
    print(l)
  else:
    print(r)

from math import ceil
from decimal import Decimal
n,m = map(int, input().split())
barn = n
if n <= m:
	print(n)
else:
	days = ceil((-1 + Decimal(1+8*(n-m)) ** Decimal(0.5))/2)
	print(days + m)

# your code goes here
n, m = map(int, input().split())
if n == 1:
  print(1)
elif m >= n - 1:
  print(n)
else:
  if m == 1:
    l = 1
    r = n
    while r - l > 1:
      mid = (l + r) // 2
      sum = mid * (mid + 1) // 2
      if n - sum + mid - 1 <= 0:
        r = mid
      else:
        l = mid
    sum = l * (l + 1) // 2
    if n - sum + l - 1 <= 0:
      print(l)
    else:
      print(r)
  else:
    r = 1000000000000000000
    frm = m + 1
    l = frm
    while r - l > 1:
      mid = (l + r) // 2
      sum = (mid - frm + 1) * (mid - frm) // 2
      if n - sum - mid <= 0:
        r = mid
      else:
        l = mid
    sum = (l - frm) * (l - frm + 1) // 2
    if n - sum - l <= 0:
      print(l)
    else:
      print(r)

n, m = map(int, input().split())
l, r = 0, n
mid = 0
for i in range(10 ** 5):
    mid = (l + r) // 2
    if n - mid * (mid + 1) // 2 - m <= 0:
        r = mid
    else:
        l = mid + 1
if n - l * (l + 1) // 2 - m <= 0:
    print(min(m, n) + l)
elif n - mid * (mid + 1) // 2 - m <= 0:
    print(mid + min(n, m))
else:
    print(r + min(n, m))

def binp(l, r, n ,d) :
    m = (l + r) // 2
    while abs(l - r) > 1 :
        m = (l+r)//2
        if m * m + m - 2 * (n - d) == 0:
            return m;
        if m*m + m - 2 * (n - d) > 0 :
            r = m;
        else :
            l = m;
    if  l*l + l - 2*(n - d) < 0 :
        return r
    else :
        return l

a = input().split()

for i in range(len(a)):
    a[i] = int(a[i])

if(a[0] != 1):
    if a[0] > a[1]:
        ans = binp(1, a[0], a[0], a[1])
        print(ans + a[1])
    else :
        print (a[0])
else :
    print(1)

n,m=(map(int,input().strip().split(' ')))
low=1
high=n
ans=1000000000000000000000000000
if(n>m):
	while(low<=high):
		mid=(high+low)//2
		t=(mid*(mid+1))//2+m

		if(t==n):
			ans=mid

			break

		if(t>n):
			ans=min(ans,mid)
			high=mid-1
		else:
			low=mid+1

	print(m+ans)
else:
	print(n)

def possi(x, n, m):
    if x<=m:
        return n-x<=0
    x-=m
    return (n-m)<=x*(x+1)/2
n, m=raw_input().split(" ")
n=int(n)
m=int(m)
if n<=m:
    print(n)
else:
    le = int(1)
    ri = int(n)
    mid = 0
    ans = 0
    while le<=ri:
        mid = (le+ri)/2
        if possi(mid, n, m) :
            ans=mid
            ri=mid-1
        else:
            le=mid+1
    print(ans)

def work(days, n, m):
    # m < n
    #print(days, n, m)
    k = days - (m+1)
    loss = (1 + k) * k // 2
    #print(loss)
    return n - loss - days <= 0

def main():
    n, m = [int(x) for x in input().split()]
    if m >= n:
        print(n)
        return
    left = m + 1
    right = n
    while left < right:
        mid = (left + right) // 2
        if work(mid, n, m):
            right = mid
        else:
            left = mid + 1
    print(left)

if __name__ == "__main__":
    main()

import math
n,m=map(int,input().split())
if(m>=n):
    print(n)
else:
    temp=min(n,m)
    a=temp+1
    res=temp
    start=1
    end=2*(10**9)
    while(start<=end):
        mid=(start+end)//2
        if(((mid)*(2*a+mid-1)//2)>n+(mid-1)*m):
            end=mid-1
        elif(((mid)*(2*a+mid-1)//2)<n+(mid-1)*m):
            start=mid+1
        else:
            start=mid
            break
    print(start+res)
    #res+=(1+2*m-2*a+math.sqrt((1+2*m-2*a)**2+8*(n-m)))/2
    #print(math.ceil(res))

import math

def f(j):
    return j * (j + 1)

def binsearch(left, right, t):
    j = (left + right) // 2
    if f(j) >= t and f(j - 1) < t:
        return j
    elif f(j) >= t and f(j - 1) >= t:
        return binsearch(left, j - 1, t)
    else:
        return binsearch(j + 1, right, t)

n, m = map(int, input().split())
if m >= n:
    # print("The answer is", n)
    print(n)
else:
    k = n - m
    res = m
    t = 2 * k
    # run binary search to find min j s.t. j(j + 1) >= t
    j = 1
    res += binsearch(1, t, t)
    print(res)

# print("The answer is", res)
# print(res)

#no language is perfect -_-

import math

n,m=map(int,raw_input().split())

if(n<=m):
    ans=n
else:
    ans=int((-1+math.sqrt(1+8*(n-m)))/2)
    while(n-m-ans*(ans+1)/2>0):
        ans+=1
    while(n-m-ans*(ans+1)/2<=0):
        ans-=1
    ans+=1
    ans+=m
print ans

import sys
n,m=map(long,raw_input().strip().split())
if m>=n:
    print n
    sys.exit()
l=0
r=long(2e9)
x=r
while l<=r:
   tmp=(l+r)/2
   if tmp*tmp+tmp>=2*(n-m):
      x=tmp
      r=tmp-1
      continue
   l=tmp+1;
print m+x

# http://codeforces.com/problemset/problem/785/C
n,m = map(int,raw_input().split())

if n<=m :
    print(n)
else :

    ans = m
    L =0
    R = 2**31-1
    while L < R :
        mid = (L+R)//2
        if mid*(mid+1)//2 >= n - m :
            R=mid
        else :
            L=mid + 1
    print(ans + L)

n, m = (int(x) for x in str(raw_input()).strip().split(' ', 1))

if n <= m:
    print(n)
    exit(0)
l = m
r = n
while l <= r:
    d = l + r >> 1;
    if 2 * n + 2 * m * (d - m - 1) + m * (m + 1) - d * (d + 1) <= 0:
        r = d - 1
    else:
        l = d + 1;
print(int(l))

import math
n,m=map(int,raw_input().split())
if m>=n:
    print n
else:
    lo,hi=1,1e18
    days=1e18
    while lo<=hi:
        mid=int((lo+hi)/2)
        val=n+(mid-1)*m-(m*mid+(mid*(mid+1))/2)
        if val>0:
            lo=mid+1
        elif val<0:
            days=min(days,mid)
            hi=mid-1
        else:
            days=min(days,mid)
            break
    print days+m

n, m = map(int, raw_input().split(" "))
if n<=m:
    print n
else:
    l = m
    r = int(1e19)
    while l<r:
        mid = int((l + r)/2)
        k = mid - m - 1;
        if mid+(k*(k+1))/2 >= n:
            r = mid
        else:
            l = mid+1
    print l

from decimal import *
n,m = map(int,raw_input().strip().split())
if(n>m):
	l = 2*(n-m)
	x = Decimal(-1+Decimal(1+4*l).sqrt())/2
	ans = x.to_integral_exact(rounding=ROUND_CEILING)
	print ans+m
else:
	print n

def fun(i, n, m):
  return i * i + i - 2 * n + 2 * m

n, m = map(int, input().split())
if m >= n:
  print(n)
  exit(0)
left, right = 1, (10 ** 18)
while left < right:
  mid = (left + right) // 2
  if fun(mid, n, m) < 0:
    left = mid + 1
  else:
    right = mid
print(left + m)

def main():

    n, m = list(map(int, input().split()))

    if m >= n:
        print(n)
        return

    def ok(x):
        return (x * (x + 1) // 2  + x * m) >= (n + m * max(0, (x - 1)))

    ll = 0
    rr = int(10**19)

    for i in range(100):
        mm = (ll + rr) // 2
        if not ok(mm):
            ll = mm
        else:
            rr = mm

    while rr > 0 and ok(rr - 1):
        rr -= 1

    while not ok(rr):
        rr += 1

    print(m + rr)

if __name__ == '__main__':
    main()

import math as ma
n,m=list(map(int,input().split()))
if n>=m:
    st=0
    end=10**20
    a=2*(n-m)
    e=0
    while st<=end:
        mid=(st+end)//2
        b=mid**2+mid
        if b==a:
            e=1
            break
        elif b>a:
            end=mid-1
        elif a>b:
            st=mid+1
    if e==1:
        print(mid+m)
    else:
        print(st+m)
else:
    print(n)

import sys

n, m = map(int, input().split())

if m>=n :
    print(n)
    sys.exit()

ans = m

lo = 1
hi = 10000000000000000000000

temp = 0

while lo<=hi :
    mid = (lo+hi)//2

    t1 = mid*(mid+1)//2

    if t1 >= (n-m) :
        temp = mid
        hi = mid-1
    else :
        lo = mid+1

print(temp+ans)

import sys
import math
from decimal import Decimal

## (x)(x+1)/2 > n; + m

line = input()
line = line.split()
n = line[0]
m = line[1]

n = Decimal(n)
m = Decimal(m)

if m >= n:
  print (n)
  sys.exit()

def f(x):
  return(math.floor((x*(x+1))/2) + x)

def search(tar,bot,top):
  bot = Decimal(bot)
  top = Decimal(top)
  curr = math.floor((bot+top)/2)
  curr = Decimal(curr)
  if (f(curr) >= tar) and (f(curr-1) < tar):
    return curr + 1
  elif f(curr) < tar:
    return search(tar,curr,top)
  elif f(curr) >= tar:
    return search(tar,bot,curr)

ans = search(n-m-1,0,2000000000) + m
print(ans)

N,M = map(long,raw_input().split());
low ,high =1, 2*10**18;
ans = high;
Y = min(N-1,M);

while(low<=high):
    mid = (low+high)/2;
    X = min( Y,mid );
    status = N+((X-1)*X)/2+(mid-X)*Y - (mid*(mid+1))/2;

    if(status<=0):
        ans ,high = mid, mid-1;
    else :
        low = mid+1;
print ans

import math

def bin_pow(a, b):
    ans = 1
    while b > 0:
        if b & 1 == 1:
            ans *= a
        a *= a
        b >>= 1
    return ans

n, m = map(int, input().split())
if m >= n:
    print(n)
else:
    ans = m
    n -= m

    left = 0
    right = int(10e18)
    while left <= right:
        # print(left, right)
        # print('--')
        mid = (left + right + 1) // 2
        if mid * (mid + 1) > 2 * n:
            right = mid - 1
        elif mid * (mid + 1) < 2 * n:
            left = mid + 1
        else:
            print(ans + mid)
            exit(0)
    while mid * (mid + 1) >= 2 * n:
        mid -= 1
    while mid * (mid + 1) < 2 * n:
        mid += 1
    print(ans + mid)

import math

n,m = map(int,raw_input().strip().split())
if n<=m:
    print n

else:
    x = int((-1+math.sqrt(1+8*(n-m)))/2.0)
    if (x*(x+1))/2 >= n-m:
        print m+x
    else:
        print m+x+1

def f(tar,n,m):
    n-=m
    bir=(tar*(tar+1))//2
    if bir>=n:
        return True
    else:
        return False

import sys

n,m=map(int,input().split())
if n<=m:
    print(n)
    sys.exit()

low,high=0,10**18
while(low<high):
    mid=low+(high-low)//2
    x=f(mid,n,m)
    if x:
        high=mid
    else:
        low=mid+1

print(low+m)

ini,gain = (int(n) for n in input().split(" "))
non_decreasing = (gain * (gain + 1)) // 2
allday = 10 ** 18
left = 0
# print(non_decreasing,gain * (gain))
if ini > gain:
    while allday > left:
        day = (allday + left) // 2
        now_decreased = (day * (day + 1)) // 2 - gain * max(0,day - gain - 1) - non_decreasing
        # print(now_decreased,day,left,allday,non_decreasing)
        if now_decreased > ini:
            allday = day
        elif now_decreased < ini:
            left = day + 1
        else:
            break
    print((allday + left) // 2)
else:
    print(ini)

inp = map(int, raw_input().split())
n, m = inp[0], inp[1]
l = m
r = n
while (r - l > 1):
    mid = (r + l) / 2
    if (n - (mid - m - 1) * (mid - m) / 2 > mid):
        l = mid
    else:
        r = mid
print r

def bs(v):
	l, h = 0, int(3e9)
	while l<h:
		m=(l+h)/2
		v1=m*(m+1)/2
		if v1>=v:
			h=m
		else :
			l=m+1

	v1=l*(l+1)/2
	if v1<v:
		return l+1
	return l

n,m=map(int,raw_input().split())

if n<=m:
	print n
else:
	print bs(n-m)+m

x = raw_input().split(' ')
n = int(x[0])
m = int(x[1])

mini = 0
maxi = min(n, 3 * 10**9)

if n < m:
	mini = n
	maxi = n
	m = 0

while maxi > mini:
	midi = (mini + maxi) / 2

	testval = m + midi * (midi + 1) / 2

	if testval == n:
		maxi = midi
		break

	if testval < n:
		mini = midi + 1
	else:
		maxi = midi

print m + maxi

import math
from decimal import Decimal
a,b = map(int,input().split())
if a<=b:
	print(a)
else:
	ans = math.ceil(((Decimal(1+8*(a-b))**Decimal(0.5))-1)/2)
	print(ans+b)

from math import ceil, sqrt

n, m = [int(i) for i in input().split()]

if m >= n:
    print(n)

else :
    l = 0
    r = 10**18
    ans = 10**18
    while (l <= r):
        mid = (l + r) // 2

        if mid * mid + mid >= 2 * (n - m):
            ans = mid
            r = mid - 1

        else:
            l = mid + 1

    print(ans + m)

def get(n):
    return (1+n)*n/2
n,m=map(int,raw_input().split())

l,r=m+1,n
while l<r:
    md=(l+r)/2
    if (get(md-1-m)+md>=n):
        r=md
    else:
        l=md+1
if (n<=m):
    print n
else:
    print l

n, m = map(int, input().split())

def s(x):
    return (1 + x) * x

def can(x):
    if x >= n:
        return True
    if x <= m:
        return False
    if (2 * n - s(x - m - 1) <= 2 * x):
        return True
    return False

r = 1000000000000000000
l = 0
while r - l > 1:
    mid = (l + r) // 2

    if can(mid):
        r = mid
    else:
        l = mid
for i in range(l, r + 1):
    if can(i):
        print(i)
        raise SystemExit

""" Created by Shahen Kosyan on 3/15/17 """
from decimal import *

if __name__ == "__main__":
    n, m = [int(x) for x in input().split()]

    if m >= n:
        print(n)
    else:
        days = Decimal((-1 + Decimal(1 + 8 * (n - m)) ** Decimal(0.5)) / 2)
        answer = days.to_integral_exact(rounding=ROUND_CEILING) + m
        print(answer)

string1 = raw_input()
list1 = string1.split()
n = int(list1[0])
m = int(list1[1])

flag = True;
if m >= n:
	print n
	flag = False;
else:
	num = (n-m)*2
	l = 0
	h = n
	while l < h:
		mid = (l+h)/2;
		if num == mid*(mid + 1):
			l =mid
			break
		elif num > mid*(mid + 1):
			l = mid + 1
		else:
			h = mid
if flag == True:
	print l + m

#!/usr/bin/python
# coding=utf-8

import math

if __name__ == '__main__':
    n, m = raw_input().split()
    n = int(n)
    m = int(m)
    if m >= n:
        print n
    else:
        ans = (math.sqrt(8 * n - 8 * m + 1) - 1) / 2
        ans = int(ans)
        while (2 + ans) * (ans - 1) < 2 * (n - m - 1):
            ans += 1
        print ans + m

import sys
n, m = map(int, input().split())
l=m+1
r=10**30
ans=n
if n==1:
	ans=1
else:
	if m<n:
		while l!=r:
			mid=(l+r)//2
			if 2 * m + ( mid - m ) * ( mid - m + 1 ) < 2 * n :
				l=mid+1
			else :
				r=mid
		ans=min(ans, l)
	else:
		ans=n
print(int(ans))

n, m = map(int, input().split())

def binary_search():
    l, r = 0, int(2e9)
    while l <= r:
        mid = l+r >> 1
        if (mid * (mid+1) // 2 >= n - m):
            r = mid-1
        else:
            l = mid+1
    return l

if (n <= m): print(n)
else: print(binary_search() + m)

n,m = map(int,raw_input().split())
if m>=n:
    print n
else:
    s = (n - (m+1))
    if(s<=0):
        print m+1
    else:
        l = m+2
        r = n
        ans = n
        while(l<=r):
            mid = (l+r)/2
            eat = ((m + 2 + mid)*(mid - (m+1)))/2
            av = s + m*(mid - (m+1))
            if (av<=eat):
                ans = mid
                r = mid - 1
            else:
                l = mid + 1

        print ans

"""
contest template, Mikhail Dektyarev <mihail.dektyarow@gmail.com>
real code is below
"""
def readint():
    return int(input())

def readfloat():
    return float(input())

def readarray(n, f=input):
    return [f() for i in range(n)]

def readlinearray(f=int):
    return list(map(f, input().split()))

#gcd, x, y; a * x + b * y = gcd
def euclide(a, b):
    if a < 0:
        g, x, y = euclide(-a, b)
        return g, -x, y
    if b < 0:
        g, x, y = euclide(a, -b)
        return g, x, -y
    if b == 0:
        return a, 1, 0
    g, x, y = euclide(b, a % b)
    return g, y, x - (a // b) * y

def gen_primes(max):
    primes = [1] * (max + 1)
    for i in range(2, max + 1):
        if primes[i]:
            for j in range(i + i, max + 1, i):
                primes[j] = 0
    primes[0] = 0
    return [x for x in range(max + 1) if primes[x]]

def is_prime(N):
    if N % 2 == 0:
        return N == 2
    i = 3
    while i * i <= N:
        if N % i == 0:
            return False
        i += 2
    return True

def answer():
    return ""

def gcj():
    n, m = readlinearray()
    m = min(n, m)
    l = 0
    r = 10**18
    while l < r:
        q = (l + r) // 2
        # if (n - q * (q + 1) // 2) <= q:
        if n - m - q * (q + 1) // 2 <= 0:
            r = q
        else:
            l = q + 1
    print(l + min(m, n))

if __name__ == "__main__":
    gcj()

n, m = list(map(int, input().split()))
l = -1
r = int(1e18 + 10)
while r - l != 1:
    t = (r + l) // 2
    eaten = t
    if (t - 1 > m):
        eaten += (t - 1 - m) * (t - m) // 2
    if eaten >= n:
        r = t
    else:
        l = t
print(r)

n, m = [int(i) for i in input().split()]

if m >= n:
    print(n)
else:
    l = 0
    r = 3000000000

    while (l < r):
        cur = (l + r) // 2
        if cur * (1 + cur) // 2 >= (n - m):
            r = cur
        else:
            l = cur + 1

    print(m + l)

n, m = [int(i) for i in input().split()]
l= min(m, n) - 1
r = 10**18
mid = -1
while(r - l > 1) :
    mid = (l + r) // 2
    a = (mid - m) * (mid - m + 1) // 2 + m
    if (a < n) :
        l = mid
    else :
        r = mid
print(r)

def calc(a, b):
    return (a + b) * (b - a + 1) // 2

n, m = map(int, raw_input().split())
m = min(n, m)
l = m
r = int(2e18)
ans = r
while l <= r:
    mid = (l + r) // 2
    if n + (mid - m) * m <= calc(m, mid):
        ans = mid
        r = mid - 1
    else:
        l = mid + 1
print(ans)

def fit(n, m, x):
    if x >= n:
        return True
    elif x - m <= 0:
        return False
    elif 2*n+2*(x-m-1)*m<=(m+1+x)*(x-m):
        return True
    else:
        return False

n, m = map(int, raw_input().strip().split())
l = 1
r = 1e18+10
while(l < r):
    x = int((l+r)/2)
    if(fit(n, m, x)):
        r = x
    else:
        l = x+1
print r

def find(l, r, kf):
    while l < r:
        m = (l + r) // 2
        if not kf(m):
            l = m + 1
        else:
            r = m

    return r

n, m = map(int, input().split())

def isEnough(i):
    return (2 * i + 1) ** 2 >= 1 + 8 * (n - m)

if m >= n:
    print(n)
else:
    d = find(1, 2*(n + m), isEnough)
    print(m + d)

import math
n,m=map(int,raw_input().split())
if m>=n:
	print n
else:
	n-=m
	check=int(math.sqrt(2*n))
	i=check
	while(1):
		if i*(i+1) < 2*n:
			print m+1+i
			break

		i-=1

n, m = map(int, input().split())
l = min(n, m)
r = n
k = min(n, m + 1)

for i in range(200):
    mid = (l + r) // 2
    if n + (mid - k) * m - (2 * k + mid - k) * (mid - k + 1) // 2 <= 0:
        r = mid
    else:
        l = mid

for i in range(l, r + 1):
    if n + (i - k) * m - (2 * k + i - k) * (i - k + 1) // 2 <= 0:
        print(i)
        break

def sum(n):
    return n * (n + 1) / 2

n, m = map(int, raw_input().strip().split(" "))

if (m >= n):
    print n
    exit(0)

l = 0
r = n - m

while (l < r):
    mid = (l + r) / 2
    if (sum(mid) >= n - m):
        r = mid
    else:
        l = mid + 1

print m + l

import math

# print raw_input().split()
n, m = [int(x) for x in raw_input().split()]
# # n = int(raw_str.split()[0])
# # m = int(raw_str.split()[1])

def bin_search(x):
	# Find k such that sum(1..k) >= x
	i = 1
	j = x
	while(j - i > 1):
		k = (i + j) / 2
		s = k * (k + 1) / 2
		if s > x:
			j = k
		elif s == x:
			i = j = k
		else:
			i = k + 1
	if i == j:
		return i
	else:
		s = i * (i + 1) / 2
		return i if s >= x else j

if n <= m:
	print n
else:
	# ival = math.sqrt(2 * (n - m) + 0.25) - 0.5
	print int(m + bin_search(n - m))

n,m=map(int,input().split())
if n<m:
    print(n)
else:
    (l, r) = (0, int(2e9))
    n-=m
    while l<r:
        mid=(l+r)//2
        val=mid*(mid+1)
        if val>=2*n:
            r=mid
        else:
            l=mid+1
    print(m+l)

n,m = map(int, raw_input().strip().split(' '))
ans = m

if m >= n:
    print n
else:
    import math
    #first = (-1 + math.sqrt(1.0 + 8 * n - 8 *m)) / 2.0
    first = math.sqrt(2*(n-m))
    temp = int(math.ceil(first))
    for i in xrange(max(temp-1,0), temp+2):
        if i*(i + 1) >= 2*(n-m):
            print ans + i
            break

n, m = map(int, raw_input().split(" "))

lt = 1
rt = n
mid = -1
ans = 0
if n <= m:
    m = n - 1

while lt <= rt:
    mid = (lt + rt) >> 1
    if ((mid + m) * (mid + m + 1) // 2 - m * (m + 1) // 2 >= n + (mid - 1) * m):
        ans = mid + m
        rt = mid - 1;
    else:
        lt = mid + 1

print (ans)

n, m = map(int, raw_input().split())
if n == 1:
    print 1
    exit()

if n <= m:
    print n
    exit()

k = m
hi = 10**18
lo = 0
while hi - lo > 1:
    mid = (hi + lo) / 2
    x = n + mid * m - (mid+k)*(mid+k+1)/2 + k*(k-1)/2
    if x <= 0:
        hi = mid
    else:
        lo = mid

print hi + k

import sys
n,m = map(int,raw_input().split())
if m>=n:
    print min(m,n)
    sys.exit()
lo = m
hi = n+1
while lo < hi:
    mid = (lo+hi)/2
    cur = mid-m
    if cur*(cur-1)/2+m<n:
        lo = mid+1
    else:
        hi = mid
print lo-1

n, m = [int(x) for x in raw_input().split()]

if m >= n:
	print n
	exit()

lo = m
hi = n+1

ans = -1

def check(start, days):
	if days > n:
		return -1
	eaten = (days+start) * (days-start+1) / 2
	received = n + (days-start) * m
	return received - eaten

while hi-lo>1:
	mid = (lo+hi)/2

	res = check(m, mid)
	if res > 0:
		lo = mid
	elif res < 0:
		hi = mid
	else:
		ans = mid
		break

if ans != -1:
	print ans
else:
	print hi

import math
n, m = map(int, input().split())

if m >= n:
    print(n)
else:
    disc = 1 + 8 * (n - m)
    dr = (-1 + pow(disc, 0.5)) / 2.0
    dr = math.ceil(dr);
    if (dr * (dr - 1) >= 2 * (n - m)) :
        dr -= 1
    if (dr * (dr + 1) < 2 * (n - m)) :
        dr += 1
    print(m + dr)

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 13 16:08:37 2017

@author: arik
"""
import math

def P(n,m,i):
    if(i <= m+2):
        return n-(i-1)
    s = ( (m+1)*(m+2) )//2
    t = ( (i)*(i-1) )//2
    x = (n-m-1) + (i-m-2)*m - t + s
    return x

def F(n, m, i):
    if(i <= m+1):
        return n-i
    return P(n,m,i) + m - i

n,m=map(int,raw_input().split())

# for i in range(1, 15):
  #  print F(n,m,i)

l=1
h=n+m+1

while(l <= h):
    mid=l+(h-l)//2
    if(F(n,m,mid) == 0 or ( F(n,m,mid)<0 and F(n,m,mid-1)>0 )):
        print mid
        break
    elif(F(n,m,mid) < 0):
        h = mid
    else:
        l = mid

def binary_search(n,nm):
    lo = 0
    hi = n
    while lo < hi:
        mid = (lo+hi)//2
        midval = mid**2 + 3*mid + 2
        if midval < nm:
            lo = mid+1
        elif midval > nm:
            hi = mid
        else:
            return mid
    return lo

[n, m] = map(int, input().split())

if n - m <= 0:
    print(n)
else:
    print(m + binary_search(n, 2*(n - m)) +1)

n, m = map(int, input().split())

l = 0
r = 10**18 + 1

def can(mid):
    if mid <= m:
        return (n - mid) > 0

    plus = (n - m) - ((mid-m) * (mid-m+1)) // 2
    return plus > 0

while r - l > 1:
    mid = (l + r) // 2
    if can(mid):
        l = mid
    else :
        r = mid

print(r);

n,m=map(int,raw_input().split())

def isempty(d):
	if d<1:return False
	if d*(d+1)/2>=m*max(0,d-m)+n+m*(m-1)/2:
		return True
	else:
		return False
def binsearch(srt,end):
	mid=(srt+end)/2
	print mid,isempty(mid)
	if srt==mid:return srt
	if isempty(mid)==True and isempty(mid-1)==False:
		return mid
	elif isempty(mid)==True:
		return binsearch(srt,mid-1)
	else:
		return binsearch(mid+1,end)

print binsearch(1,n)

from math import floor,sqrt,ceil

s,m=map(int,raw_input().split())
if s<=m:
    print 1
else:
    d=int(sqrt(2*(s-m)))
    if d*(d+1)>=2*(s-m) and d*d<=2*(s-m):
        print m+d
    elif d*(d+1)<=2*(s-m) and (d+1)*(d+2)>=2*(s-m):
        print m+d+1
    else:
        print m+d-1

from decimal import Decimal
from math import ceil, sqrt

n, m = map(int, raw_input().split())

if m > n:
    print n
else:
    temp = Decimal(1 + 4*(2*n - 2*m))
    #print temp
    ans = (-1 + temp.sqrt())/2
    #print ans
    print int(ceil(ans)) + m

n, m = map(int, input().split())
if m>=n:
    print(n)
else:
    l = 1
    r = 2000000000
    for i in range(100):
        mid = (l + r) / 2
        mid = int(mid)
        if((mid) * (mid - 1) / 2 + mid + m >= n):
            r = mid
        else:
            l = mid
    print(m + r)

from math import ceil
from math import sqrt

n, m = map(int, input().split())

if n < m:
    print(n)
else:
    k = ceil(.5 * sqrt(-8 * m + 8 * n + 1) - .5)
    day = int(m + k)
    print(day)

input=__import__('sys').stdin.readline
n,m = map(int,input().split())
l=0
r=1000000000000000000000000
while l<=r:
    mid = l +(r-l)//2
#    print(n-(mid*(mid+1))//2,m+1+mid,mid,l,r)
    if n-(mid*(mid+1))//2>=m+1+mid:
        l=mid+1
    else:
        r=mid-1
#print(l,r)
if n-(r*(r+1))//2 <= m+r+1:
    print(m+r+1)
else:
    print(l+m+1)

def f(n, m):
	sz = n
	n -= 1
	step = 2
	while n > 0:
		n += m
		n = min(n, sz)
		n -= step
		step += 1
	return step - 1

n, m = map(int, input().split())
cnt = max(n - m, 0)
l = 0
r = 10 ** 18
while l + 1 < r:
    m1 = (l + r) // 2
    x = (m1 * (m1 - 1)) // 2
    if x <= cnt:
        l = m1
    else:
        r = m1
print(m + l)

from sys import stdin, stdout

n, k = map(int, stdin.readline().split())
k = min(k, n)

D = 9 + 8 * (n - k - 1)
day1 = (D ** 0.5 - 3) / 2

if day1 == int(day1):
    stdout.write(str(int(day1) + 1 + k))
else:
    stdout.write(str(int(day1) + 2 + k))

n, m = map(int, input().split())

l = 1
r = 10**18 + 1

def can(mid):
    if mid <= m:
        return (n - mid) > 0

    plus = (n - m) - ((mid-m) * (mid-m+1))/2
    return plus > 0

if can(1):

    while r - l > 1:
        mid = (l + r) // 2
        if can(mid):
            l = mid
        else :
            r = mid

    print(r);

else :
    print(1);

from math import ceil

n, m = map(int, raw_input().split())

if m > n:
    print n
else:
    temp = float(1 + 4*(2*n - 2*m))

    ans = (-1 + (temp)**0.5)/2

    print int(ceil(ans)) + m

from math import *
a, b = [int(x) for x in input().split(' ')]
print(ceil(sqrt(2*(a-b)+0.25)+b-0.5))

import math
n,m=map(int,input().split())
if(m>=n):
    print(n)
else:
    temp=min(n,m)
    a=temp+1
    res=temp
    start=1
    end=1e18
    while(start<=end):
        mid=(start+end)//2
        if(((mid)*(2*a+mid-1)//2)>n+(mid-1)*m):
            end=mid-1
        elif(((mid)*(2*a+mid-1)//2)<n+(mid-1)*m):
            start=mid+1
        else:
            start=mid
            break
    print(int(start+res))
    #res+=(1+2*m-2*a+math.sqrt((1+2*m-2*a)**2+8*(n-m)))/2
    #print(math.ceil(res))

import math

n, m = map(int, raw_input().split())

print int(math.ceil( (-1 + math.sqrt(1 + 8 * (n - m))) / 2. + m ))

n, m = map(int, input().split())
if m >= n:
    print(n)
else:
    n -= m
    l, r = 0, n
    while l < r:
        mid = (l + r) // 2
        if (1 + mid) * mid / 2 >= n:
            r = mid
        else:
            l = mid + 1
    print(l + m)

#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]

#-------------------------code---------------------------#
#vsInput()

def remainingGrain(x):
    eaten=x*(x-1)//2
    grain=k*(x-k) + k*(k-1)//2 +n
    #print(grain,eaten,x)
    left=grain-eaten
    return left<=x

n,k=value()
if(k>=n):
    print(1)
    exit()

ans=1
low=k
high=10**18

while(low<=high):

    mid=(low+high)//2

    if(remainingGrain(mid)):
        ans=mid
        high=mid-1
    else:
        low=mid+1

print(ans)

import math

def f(i):
    return int(i*(i+1)/2)

def solve(n,m):
    lo = 0
    hi = int(10**18)
    while(lo < hi):
        mid = int((lo+hi)/2)
        print("mid " + str(mid))
        if n - f(mid) <= m:
            hi = mid
        else:
            lo = mid+1
    return mid + m

def main():
    a = list(map(int,input("").split(" ")))
    n,m = a
    print(min(n,solve(n,m)))
    return

main()

n,m = map(int, raw_input().strip().split(' '))
ans = m

if m >= n:
    print n
else:
    import math
    first = (-1 + math.sqrt(1.0 + 8 * n - 8 *m)) / 2.0
    temp = int(math.ceil(first))
    temp -= 1
    if temp*(temp + 1) >= 2*(n-m):
        print ans + temp
    else:
        temp += 1
        if temp*(temp + 1) >= 2*(n-m):
            print ans + temp
        else:
            print ans + temp + 1

inp=(raw_input(""))
inp=inp.split(' ')
n=int(inp[0])
m=int(inp[1])

k=m
n=n-m

x=0
y=0
z=5000000000

while x<z:
    y=(x+z)/2
    j=y*(y+1)/2

    if j<n:
        x=y+1
    else:
        z=y

k=k+z
print(k)

n, m = map(int, raw_input().split())

print (m+n)/(m+1) + m

__author__ = 'zihaozhu'
from sys import stdin
import math

capacity,grain = map(int,stdin.readline().split())
totalcap = capacity+grain

startingday = grain+1
if capacity<=grain:
    print(capacity)
else:
    days=0
    start = startingday
    lo = 0
    hi =int(2e9)
    ans =0
    capacity-=grain
    while lo<hi:
        mid = (lo+hi)//2
        #print(lo,hi)
        #print("mid",mid)
        val = mid*(mid+1)/2
       #print(val)
        if val >= capacity:
            hi = mid
            ans = mid
            #print("is it true")
        else:
            lo = mid +1

    #print("mid",mid)

    # print("ans",ans)
    # print("grain",grain)
    print(startingday+lo-1)

def sm(l, r):
	return (r + 1) * r / 2 - (l - 1) * l / 2

n, m = map(int, input().split())

if n <= m:
	print(n)
else:
	l = -1
	r = n + 1

	while r - l > 1:
		mid = int((l + r) / 2)

		if n - sm(1, mid) > m:
			l = mid
		else:
			r = mid

	print(m + r)

from math import *
a, b = [int(x) for x in input().split(' ')]
if a<b:
    print(a)
else:
    print(ceil(sqrt(8 * a - 8 * b + 1)/2 - 0.5)+b)

def f(n, m):
	sz = n
	n -= 1
	step = 2
	print('n = ', n)
	while n > 0:
		n += m
		n = min(n, sz)
		n -= step
		step += 1
	return step - 1

n, m = map(int, input().split())
m = min(m, n)
cnt = max(n - m, 0)
l = 0
r = 10 ** 18
while l + 1 < r:
    m1 = (l + r) // 2
    x = (m1 * (m1 + 1)) // 2
    if x < cnt:
        l = m1
    else:
        r = m1
print(m - 1 + r)

import math
n, m = map(int, raw_input().split())
if n <= m:
    print n
else:
    print m + int(math.ceil((math.sqrt(8 * (n-m) + 1) - 1)/2))

n, m = map(int, input().split(' '))
i = m
j = 0
if n > m:
	while j * (1 + j) / 2 < n:
		j += 1
print(i + j)

# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

import math

n,m = input().split()

#print(str(n)+str(m))
n = int(n)
m = int(m)

ans = min(n,m)
n-=m
n = max(n,0)
x = -1
y = int(math.sqrt(n))

i = y - 10
while(i<y+10):
    #print(i)
    if(i<=0):
        i+=1
        continue
    p = i
    q = i+1
    if(p%2):
        q/=2
    else:
        p/=2
    if(p*q<n):
        i+=1
        continue
    if(x==-1):
        x = i
    else:
        x = min(x,i)

    i+=1

if (x==-1):
    x=0
ans +=x
print(ans)

from math import ceil
n,m = map(int,input().split())
if m >= n:
    print(n)
else:
    #num = 0 <= n2**2 + n2 - (n - m)*2
    num2 =  (n - m)*2
    num2 = num2 * 4 + 1.0
    num3 = num2
    num2 = num2 ** 0.5
    num = int((-1 + (num2))/2)
    num -= 10
    while True:
        if (n - m)*2 - (num * (num+1)) <= 0:
            break
        num += 1
    print(num + m)

s = input().split(' ')
n = int(s[0])
m = int(s[1])

if m >= n:
    print(n)
else:
    print(m + 1 + (n-m)//2)

n, m = map(int, raw_input().split(" "))

lt = 1
rt = n
mid = -1
ans = 0

while lt <= rt:
    mid = (lt + rt) >> 1
    if ((mid + m - 1) * (mid + m) / 2 >= n + (mid - 1) * m):
        ans = mid + m - 1
        rt = mid - 1;
    else:
        lt = mid + 1

print (ans)

#!/usr/bin/env python3
from sys import stdin,stdout

import math

def ri():
    return map(int, input().split())

n, m = ri()

if m-n+1 >= 0:
    print(n)
    exit()

k = n-m
l = (1+8*k)**0.5
a1 = (-1 + l)/2
a2 = (-1 - l)/2

if a1 > 0 and a1 + m >= m + 1:
    ans = m + math.ceil(a1)
else:
    ans = m + math.floor(a2)

print(ans)

from math import ceil, sqrt
def f(n, m):
  if m >= n:
    return n

  n -= m
  d1 = ceil((-1 + sqrt(1 + 8 * n)) / 2)
  d2 = ceil((-1 - sqrt(1 + 8 * n)) / 2)
  d = d2 if d2 > 0 else d1
  return d + m

n, m = list(map(int, input().split()))
print(f(n, m))

from math import *
from collections import *
from random import *
from bisect import *
import sys
input=sys.stdin.readline
def lis():
    return list(map(int,input().split()))
def ma():
    return map(int,input().split())
def inp():
    return int(input())
def fk(a,s,k):
    b=[]
    for i in range(len(a)):
        b.append(a[i]+(i+1)*k)
    b.sort()
    return sum(b[:k])
n,m=ma()
if(m>=n):
    print(n)
    exit(0)
re=m
c=(-1+((1+8*(n-m))**(0.5)))/2
c=ceil(c)
print(c+re)

import sys
import math
n, m = map(int, input().split())
def ans(nn):
    print(nn)
    sys.exit()

if n <= m:
    ans(n)

C = n
if n < 100000:
    d = 0
    while n>0:
        #this is d day
        d += 1
        n = min(C, n + m) - d
    ans(d)

t = n - m

if t < 100000000:
    k = 0
    while k*(k+1)/2 < t:
        k +=1
    ans(m + k)
k = int(math.sqrt(2*t)) - 10000
while k*(k+1)/2 <t:
    k+=1
ans(m+k)

def f(x):
    return x*(x+1)//2

n,m=map(int, input().split())
n=10000
n=n*n*n
print(n)
if m>=n: print(n)
else:
    amount=n-m
    ans=m
    l=0
    r=min(2000000000,n)
    while l+1<r:
        m=(l+r)//2
        if f(m)<amount: l=m+1
        else: r=m
    if f(l)>=amount: ans+=l
    else: ans+=r
    print(ans)

from sys import stdin, stdout
from math import sqrt

n, k = map(int, stdin.readline().split())
k = min(k, n)

def sqrtt(x):
    l = 1
    r = x

    while (r - l > 10 ** (-6)):
        m = (r + l) / 2

        if m * m >= x:
            r = m
        else:
            l = m

    if int(r) * int(r) >= x:
        return int(r)
    else:
        return r

D = 9 + 8 * (n - k - 1)
day1 = (sqrtt(D) - 3) / 2

if day1 == int(day1):
    stdout.write(str(int(day1) + 1 + k))
else:
    stdout.write(str(int(day1) + 2 + k))

x = raw_input().split(' ')
n = int(x[0])
m = int(x[1])

mini = 0
maxi = min(n, 3 * 10**9)

while maxi > mini:
	midi = (mini + maxi) / 2

	testval = m + midi * (midi + 1) / 2

	if testval == n:
		maxi = midi
		break

	if testval < n:
		mini = midi + 1
	else:
		maxi = midi

print m + maxi

n,m = map(int, raw_input().strip().split(' '))
ans = m

if m >= n:
    print n
else:
    import math
    first = (-1 + math.sqrt(1.0 + 8 * n - 8 *m)) / 2.0
    temp = int(math.ceil(first))
    for i in xrange(max(temp-2,0), temp+3):
        if i*(i + 1) >= 2*(n-m):
            print ans + i
            break

from math import ceil

n, m = map(int, raw_input().split())

if m>=n:
    print m+1
else:
    temp = 1 + 4*(2*n - 2*m)

    ans = (-1 + (temp)**0.5)/2

    print int(ceil(ans)) + m

__author__ = 'zihaozhu'
from sys import stdin
import math

def findx(x,y,startingday):
    if (y*2)<(x+startingday) * (x-startingday+1):
        return True
capacity,grain = map(int,stdin.readline().split())
# print(capacity,grain)
totalcap = capacity+grain

startingday = grain+1

# print(startingday)
# print(totalcap)
#days = math.floor(((totalcap * 2) + (startingday**2))**0.5)

days=0
start = startingday
lo = 0
hi =totalcap

while lo<hi:
    mid = (lo+hi)//2
    if findx(mid,totalcap,startingday):
        hi = mid
    else:
        lo = mid +1

#print("mid",mid)

print(mid)

def s(x):
    return (1 + x) // 2 * x

def can(x):
    if x >= n:
        return True
    if x <= m:
        return False
    if (n - s(x - m - 1) <= x):
        return True
    return False

n, m = map(int, input().split())

r = 1000000000000000000
l = 0
while r - l > 1:
    mid = (l + r) // 2

    if can(mid):
        r = mid
    else:
        l = mid
for i in range(l, r + 1):
    if can(i):
        print(i)
        raise SystemExit

n, m = map(int, input().split())
# NNNNYYYY

low = (int)(-m+1)
high= (int)(10000000000000)
while low<high:
    mid = (int)(low + (int)((high-low)/2))
    if (int)(mid*(mid+1)) >= (int)((n-m)*2):
        high=mid
    else:
        low = mid+1

if low*(low+1) < (n-m)*2:
    low+=1
print((int)(low+m))

n,m = map(int, raw_input().strip().split(' '))
ans = m

if m >= n:
    print n
else:
    import math
    first = (-1 + math.sqrt(1.0 + 8 * n - 8 *m)) / 2.0
    #first = math.sqrt(2*(n-m))
    temp = int(math.ceil(first))
    for i in xrange(max(temp-1,0), temp+2):
        if i*(i + 1) >= 2*(n-m):
            print ans + i
            break

n, m = map(int, input().split())

def c(n):
    return (1 + n) * (n) // 2

def md(a, b):
    return (a + b) // 2

if n <= m:
    print(n)
else:
    a = 0
    if n - m - 1 <= 0:
        print(m + 1)
    else:
        l = 0
        r = int(1e10)
        r - l >= 0
        nn = n - m - 1
        while r - l >= 1:
            # print([l, r, md(l, r)], c(md(l, r)), nn)
            if c(md(l, r)) < nn:
                l = md(l, r) + 1
                a = c(md(l, r))
                # print("a", a)
            else:
                r = md(l, r) - 1
        print(min(l, r) + m + 1)

n, m = map(int, raw_input().split(" "))
if n == m:
    print n
i = 0
while True:
    i += 10000
    if i*(i+1)/2 + m >= n:
        break
i -= 10000
while True:
    i += 1000
    if i*(i+1)/2 + m >= n:
        break
i -= 1000
while True:
    i += 100
    if i*(i+1)/2 + m >= n:
        break
i -= 100
while True:
    i += 10
    if i*(i+1)/2 + m >= n:
        break
i -= 10
while True:
    i += 1
    if i*(i+1)/2 + m >= n:
        break
print i + m

n, m = map(int, input().split())

mskip = (m + 1) // 2 * (m) if m % 2 else (m) // 2 * (m + 1)
l = m + 2
r = 10**18
gi = 0

while l <= r:
    i = (l + r) // 2
    irem = ((i + 1) // 2 * i if i % 2 else i // 2 * (i + 1)) - mskip
    addi = (i - m - 1) * m + n

    if irem >= addi:
        gi = i
        r = i - 1
    else:
        l = i + 1

print(gi)

def solution():
    n, m = map(int, input().split())

    ans = m + 1
    if n - ans > 0:
        alfa = n - ans
        lo, hi = 0, 10 ** 20
        while lo != hi:
            mid = ( lo + hi ) // 2
            if mid * ( mid + 1 ) >= 2 * ( alfa - 1 ):
                hi = mid
            else:
                lo = mid + 1
        ans += lo
    ans = min(ans, n)
    print(ans)

if __name__ == '__main__':
    solution()

from math import sqrt
from math import ceil
from math import floor
n,m = list(map(int, input().split()))
barn = n
if n < m:
	print(n)
else:
	sq = sqrt(m)
	days = floor(sq)
	while True:
		if barn - days <= 0:
			break
		barn += (m - days)
		days += 1
	print(days)

#!/usr/bin/python
# coding=utf-8

import math

if __name__ == '__main__':
    n, m = raw_input().split()
    n = int(n)
    m = int(m)
    if m >= n:
        print n
    else:
        ans = ((2 * m + 1) + math.sqrt((2 * m + 1) * (2 * m + 1) - 4 * (m * m + m - 2 * n))) / 2;
        while (ans - m) * (ans - m - 1) < 2 * n:
            ans += 1
        print int(ans) - 1

n, m = map(int, input().split())

l = 0
r = 10**18 + 1

def can(mid):
    if mid <= m:
        return (n - mid) > 0

    plus = (n - m) - ((mid-m) * (mid-m+1))/2
    return plus > 0

while r - l > 1:
    mid = (l + r) // 2
    if can(mid):
        l = mid
    else :
        r = mid

print(r);

import math
n,m=list(map(int,input().split()))
i=0
curr=m+1
start=n
n=n-m-1
a1=m+1
k1=(1-2*a1+math.sqrt(1-4*a1+4*a1*a1+8*n))/2
k1=math.ceil(k1)
k1=k1+curr
if m>start:
    print(start)
else:
    print(k1)

from sys import stdin
from math import ceil, sqrt
n, m = map(int, stdin.read().split())
j = min(m, n -1)
print int(j + ceil(m - j - 0.5 + sqrt((m - j - 0.5) ** 2 + 2 * (n - j))))

import math
from decimal import Decimal
a,b = map(int,input().split())
if a<=b:
	print(a)
else:
	ans = math.ceil((-1+math.sqrt(Decimal(1+8*(a-b))))/2)
	print(ans+b)

def sm(l, r):
	return (r + 1) * r / 2 - (l - 1) * l / 2

n, m = map(int, input().split())

if n <= m:
	print(n)
else:
	l = -1
	r = n + 1

	while r - l > 1:
		mid = int((l + r) / 2)

		if n - sm(1, mid) > m:
			l = mid
		else:
			r = mid

	print(m + r)

n, m = list(map(int, input().split()))
l = -1
r = int(1e18 + 1)
while r - l != 1:
    t = (r + l) // 2
    if t >= n or (t - m) * (t - m + 1) // 2 + m >= n:
        r = t
    else:
        l = t
print(r)

import math
from decimal import Decimal
n, m = map(int, raw_input().split())

if n<m+1:
	print n
	exit(0)

if n>m+1:
	D = math.sqrt( Decimal(1+8*(n-m)) )
	x1 = int(math.ceil(( 1+D)/2 ))
	print x1+m-1

def check(mid):
    global n, m
    return n + m * mid - (m + mid + 1) * (m + mid + 2) // 2 + m * (m + 1) // 2 <= 0

n, m = map(int, input().split())
if m >= n:
    print(n)
else:
    ans = m + 1
    l = 0
    r = n + 1
    while (r - l > 1):
        mid = (r + l) // 2
        if check(mid):
            r = mid
        else:
            l = mid
    ans += r
    print(ans)

n, m = map(int, input().split())
if m >= n:
    print(n)
else:
    n -= m
    l, r = 0, int(2e9)
    while l < r:
        mid = (l + r) // 2
        if (1 + mid) * mid / 2 >= n:
            r = mid
        else:
            l = mid + 1
    print(l + m)

import math as ma
from decimal import *
getcontext().prec = 30
n,m=list(map(int,input().split()))
if n>=m:
    b=Decimal(ma.sqrt(Decimal(1+8*(n-m))))
    a=Decimal((-1+Decimal(b))/2)
    print(ma.ceil(a)+m)
else:
    print(n)

n, m = map(int, input().split())
# NNNNYYYY

low = -m+1
high= 4e18
while low<high:
    mid = low + (int)((high-low)/2)
    if mid*(mid+1) >= (n-m)*2:
        high=mid
    else:
        low = mid+1

print(low+m)

#!/usr/bin/env python3
from sys import stdin,stdout

import math

def ri():
    return map(int, input().split())

n, m = ri()

if m-n >= 0:
    print(n)
    exit()

k = n-m
l = (1+8*k)**0.5
a1 = (-1 + l)/2
a2 = (-1 - l)/2

if a1 > 0 and a1 + m >= m + 1:
    ans = m + math.ceil(a1)
else:
    ans = m + math.floor(a2)

print(ans)

n, m = [int(x) for x in input().split()]
def b_search(left,right):
    if left==right:
        return left
    middle=(left+right)//2 #day to choose
    # print(middle)
    _l=2*(n+m*(middle-m-1))
    _r=(m+1+middle)*(middle-m)
    holds=(_l<=_r) or (middle>=n)
    if not holds:
        return b_search(middle+1,right)
    else:
        return b_search(left,middle)
print(b_search(1,10**18+3))

#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]

#-------------------------code---------------------------#
#vsInput()

def remainingGrain(x):
    eaten=x*(x-1)//2
    grain=k*(x-k) + k*(k-1)//2 +n
    #print(grain,eaten,x)
    left=grain-eaten
    return left<=x

n,k=value()

ans=n
low=k
high=10**18

while(low<=high):

    mid=(low+high)//2

    if(remainingGrain(mid)):
        ans=mid
        high=mid-1
    else:
        low=mid+1

print(ans)

s = input().split(' ')
n = int(s[0])
m = int(s[1])

if m >= n:
    print(n)
else:
    print(m + 1 + (n-m)//2)

(n,m) = map(int, input().split())
if (n <= m):
    print (n)
else:
    aM = m
    n = n - m
    l = 0
    r = 2e9
    while (l < r):
        m = (l + r)/2
        val = m*(m+1) / 2
        if (val >= n):
            r = m
        else:
            l = m + 1
    print (l + aM)

#!/usr/bin/env python

m, n = map(int, input().split())
#  print(m, n)
daypassed = n + 1
remain = m - n - 1
#  print('at day', daypassed, ': remain', remain)

start = daypassed + 1 - n
#  print(start)
l = 0
r = 1e9
while r - l > 1:
    m = (l + r) // 2
    if 0.5 * m ** 2 + (start - 0.5) * m >= remain:
        r = m
    else:
        l = m + 1
print(int(daypassed + r))

n,m = map(int, raw_input().strip().split(' '))
ans = m

if m >= n:
    print n
else:
    import math
    first = (-1 + math.sqrt(1.0 + 8 * n - 8 *m)) / 2.0
    temp = int(math.ceil(first))
    for i in xrange(max(temp-2,0), temp+3):
        if i*(i + 1) >= 2*(n-m):
            print ans + i
            break

def f(x):
    return x*(x+1)//2

n,m=map(int, input().split())
n=10000
n=n*n*n
print(n)
if m>=n: print(n)
else:
    amount=n-m
    ans=m
    l=0
    r=min(2000000000,n)
    while l+1<r:
        m=(l+r)//2
        if f(m)<amount: l=m+1
        else: r=m
    if f(l)>=amount: ans+=l
    else: ans+=r
    print(ans)

L = input().split()
n = int(L[0])
m = int(L[1])

if m>=n:
    print(n)
else:
    from math import ceil,sqrt
    print(ceil((-1+sqrt(1+8*(n-m)))/2.0) + m)

n, m = map(int, input().split())
if m>=n:
    print(n)
else:
    l = 1
    r = 2000000000
    for i in range(100):
        mid = (l + r) / 2
        mid = int(mid)
        if(int((mid) * (mid + 1) / 2) + m >= n):
            r = mid
        else:
            l = mid
    print(m + r)

import sys

def main(argv):
	n, m = [int(x) for x in raw_input().split(' ')]

	day = min(n, m)
	full = min(n, n + m * (m - 1) / 2)

	ans = 0
	while full > 0:
		ans += 1
		k = ans + day
		full = min(n, full + m)
		full -= k

	print day + ans

if __name__ == '__main__':
	main(sys.argv)

from math import sqrt, floor
s=input().split()
n=int(s[0])
m=int(s[1])
r=(sqrt(1+8*(n-m))-1)/2
k=floor(r)
for i in range(k-1,k+3):
    if i*(i+1)>=2*(n-m):
        x=i
        break
print(m+x)

n,d=map(int,input().split())
l=1
r=int(1e18)

while r-l > 1:
    m = l+(r-l)//2
    m1 = max(0, m-d)
    res = n - m1*(m1-1)//2 - m
    if res < 0:r = m
    elif res > 0:l = m
    else:
        r = m
        break

print(r)

x = raw_input().split(' ')
n = int(x[0])
m = int(x[1])

mini = 0
maxi = min(n, 3 * 10**9)

while maxi > mini:
	midi = (mini + maxi) / 2

	testval = m + midi * (midi + 1) / 2

	if testval == n:
		maxi = midi
		break

	if testval < n:
		mini = midi + 1
	else:
		maxi = midi

print m + maxi

import math

s = input().split()
n = int(s[0])
m = int(s[1])

if n <= m:
    print(n)
else:
    x = math.ceil((-1+math.sqrt(1+8*(n-m)))/2)
    print(m+x)

import sys
n, m = map(int, input().split())
l=m-1
r=n+1
ans=0
if n==1:
	ans=1
else:
	if m<n:
		while l<=r:
			mid=(l+r)/2
			i=mid
			x=(i-m-1)*m+n
			y=((i-m)*(i+m+1))/2
			if y>=x :
				ans=i
				r=i-1
			else :
				l=i+1
	else:
		ans=n
print(int(ans))

# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

import math

n,m = input().split()

#print(str(n)+str(m))
n = int(n)
m = int(m)

ans = min(n,m)
n-=m
n = max(n,0)
x = -1
y = int(math.sqrt(n))

i = y - 10
while(i<y+10):
    #print(i)
    if(i<=0):
        i+=1
        continue
    p = i
    q = i+1
    if(p%2):
        q//=2
    else:
        p//=2
    if(p*q<n):
        i+=1
        continue
    if(x==-1):
        x = i
    else:
        x = min(x,i)

    i+=1

if (x==-1):
    x=0
ans +=x
print(ans)

from math import ceil
n, m = map(int, input().split())
if n > m:
    print(m + int(ceil((n - m + 1) / 2)))
else:
    print(n)

n, m = [int(i) for i in input().split()]
l= m
r = 10**18
mid = -1
while(r - l > 1) :
    mid = (l + r) // 2
    a = (mid - m) * (mid - m + 1) // 2 + m
    if (a < n) :
        l = mid
    else :
        r = mid
print(r)

import decimal

n,m=map(int,input().split())

if(n<=m):
    print(n)
else:
    decimal.getcontext().rounding=decimal.ROUND_CEILING;
    print(decimal.MAX_PREC)
    decimal.getcontext().prec=1000;
    print(((decimal.Decimal(1+8*(n-m)).sqrt()-1)/2+m).to_integral_exact())

n,m = map(int,input().split())
x = m+1
d=0
for i in range(10**5):
    if n-i<=x+(i*(i+1)//2):
        d=i
        break
print(x+d)

import math

cap, fill = map(int, input().split())

corn = cap

if fill < cap:
#     d = fill
#
#     while True:
#         corn -= d
#         if corn <= 0:
#             break
#         d += 1
#         corn += fill
#
#     print(d)
#
# else:
#     print(cap)

    days = 0.5 * ((8 * cap + 1) ** 0.5 - 1)
    days = math.ceil(days)
    #print(days)
    print(days + 1)

else:
    print(cap)

def cal(x):
	cnt = x
	cnt += ((x-m-1)*(x-m))/2
	return n<=cnt

l=map(int,raw_input().split(' '))
n = l[0]
m = l[1]

if m>=n :
	print n
else :
	lo = 0
	hi=1000000000000000000
	ret = 1
	while lo<=hi :
		mid = lo + (hi-lo+1)/2
		if cal(mid):
			ret = mid
			hi = mid-1
		else :
			lo = mid+1
	print ret

__author__ = 'zihaozhu'
from sys import stdin
import math

capacity,grain = map(int,stdin.readline().split())
totalcap = capacity+grain

startingday = grain+1

days=0
start = startingday
lo = 0
hi =int(2e9)
ans =0
capacity-=grain
while lo<hi:
    mid = (lo+hi)//2
    #print(lo,hi)
    #print("mid",mid)
    val = mid*(mid+1)/2
   #print(val)
    if val >= capacity:
        hi = mid
        ans = mid
        #print("is it true")
    else:
        lo = mid +1

#print("mid",mid)

# print("ans",ans)
# print("grain",grain)
print(startingday+lo-1)

def main():
    QWE = 'insert'
    INF = 10 ** 9 + 9
    EPS = 10 ** -10

    import sys, math, re
    #fi = open('input.txt', 'r')
    #fo = open('output.txt', 'w+')
    #fi = open(QWE +".in", "r")
    #fo = open(QWE + ".out", "w+")
    #n, m, k = map(int, input().split(' ', 2))
    n, m = map(int, input().split(' ', 1))
    #n = int(input())
    #n, k = map(int, fi.readline().split(' ', 1))
    l, r, n = 0, INF * INF, n - m
    while l + 1 < r:
        mid = (l + r) // 2
        if (mid * (mid + 1) // 2 >= n):
            r = mid
        else:
            l = mid
    print(r + m)

main()

n, m = map(int, input().split())
if n <= m:
    print(n)
else:
    l = m - 1
    r = int(2e18)
    while r - l > 1:
        mid = (r + l) // 2
        if n - (mid - 1 - m) * (mid - m) / 2 <= mid:
            r = mid
        else:
            l = mid
    print(r)

n,m = map(int,raw_input().split())
def check(a):
	return (1+a)*a < n*2
ans = m
n = n - m
l = 0
r = 100010000000
while l < r:
	mid = (l+r)/2
	if(check(mid)):
		l = mid + 1
	else:
		r = mid
l = l + check(l)
print ans + l

import math
n, m = map(int, input().split())
if n > m:
    print(math.ceil(-0.5 + (2*(n - m))**(0.5)) + m)
else:
    print(n)

n, m = map(int, input().split())

k = 0
l = 0
r = n
for i in range(200):
    k = l + (r - l) // 2
    res = ((2 * m + k + 1) * k) // 2 - m * (k - 1)
    if res - k < n and res >= n:
        break
    elif res - k > n:
        r = k
    else:
        l = k

if m + k > n:
    print(n)
else:
    print(m + k)

from math import ceil, sqrt

n, m = [int(i) for i in input().split()]

if m >= n:
    print(n)

else :
    just = -1 + sqrt(1 + 8 * (n - m))
    just /= 2
    just = ceil(just)
    print(m + just)

import math
n,m=map(int,input().split())
if(m>=n):
    print(n)
else:
    temp=min(n,m)
    a=temp+1
    res=temp
    start=0
    end=2*(10**9)
    while(start<=end):
        mid=(start+end)//2
        if(int((mid)*(2*a+mid-1)/2)>n+(mid-1)*m):
            end=mid-1
        elif(int((mid)*(2*a+mid-1)/2)<n+(mid-1)*m):
            start=mid+1
        else:
            start=mid
            break
    print(start+res)
    #res+=(1+2*m-2*a+math.sqrt((1+2*m-2*a)**2+8*(n-m)))/2
    #print(math.ceil(res))


a, b = raw_input().split()

if a == b: print a
else:   print '1'

a,b=map(int,raw_input().split())
print a if a==b else 1 if a<b else gcd(a,b)

a, b = raw_input().split(' ')

if a == b:
    print a
else:
    print 1

from fractions import gcd

inp = raw_input()

arr = inp.split(' ')

n1 = int(arr[0])
n2 = int(arr[1])

ans = n1

# for x in range(n1,n1+1):
# 	ans = gcd(ans,x)
# 	pass

# print arr[0],"\n\n",arr[1],"\n\n"
if n1 == n2:
	print n1
else:
	print 1

def gcd(a,b):
	if a==b:
		print(str(a))
	else:
		print(1)

a,b = map(int,input().split(" "))

gcd(a,b)

a, b = map(int, raw_input().split())
print a == b and a or 1

a, b = map(int, input().split())

if a == b:
    print("{}".format(a))
else:
    print("{}".format(1))

def main():
    from sys import stdin, stdout

    a,b = map(int, raw_input().split())
    if a == b:
        stdout.write(str(a))
    else:
        stdout.write(str(1))

if __name__ == "__main__":
    main()

def gcd(a, b):
    if(a == b):
        return a
    else:
        return 1
def main():
    var1, var2 = [int(x) for x in raw_input().split()]
    print(gcd(var1,var2))
main()

from fractions import gcd
a,b = map(int,raw_input().split(' '))
if a == b:
    print a
else:
    print 1

import math
x, y=map(int, input().split())
if x==y:
  print(x)
else:
  print("1")

#Complicated GCD
from math import gcd
a,b = map(int,input().split())
li = []
if b-a >=50:
    ans = 1
else:
    for i in range(a,b+1):
        li.append(i)
    if len(li)==1:
        ans = li[0]
    else:
        for i in range(len(li)-1):
            ans = gcd(li[i],li[i+1])
            if ans == 1:
                break
print(ans)

a , b = map(int, raw_input().split())
if a == b: print a
else: print 1

a,b=raw_input().split()
if a != b:
    print 1
else:
    print a

def gcd(a, b):
    if a % b == 0: return b
    return gcd(b, a%b)

a, b = map(lambda x: int(x), raw_input().split())
print a if a == b else "1"

number = map(int,raw_input().split())

if number[0] == number[1] :
  print number[0]
else:
  print 1

x=raw_input().split()
a=int(x[0])
b=int(x[1])
if a==b:
    print a
else:
    print 1

m,n = map(int, raw_input().split())
if m==n:
    print m
else:
    print 1

a=input().split()
a=[int(i) for i in a]
if(a[0]==a[1]):
    print(a[0])
    quit()
if(max(a)-min(a)>30):
    print(1)
    quit()
a=[i for i in range(a[0],a[1]+1)]
import fractions

def rec(a):
    if(len(a)==1):
        #print(a[0])
        return a[0]
    else:
        q=a[0]
        g=a[1]
        a.remove(g)
        a[0]=fractions.gcd(q,g)
        #print(q,g,a[0])
        return rec(a)
print(rec(a))

def getGCD(a, b):
  if b == 0: return a
  return getGCD(b, a%b)

def solve(a, b):
  if a == b: return a
  return 1

A, B = [int(i) for i in input().split()]
print(solve(A, B))

x, y = map(int,input().split(' '));
if (x==y):print(x)
else: print(1)

if __name__ == '__main__':
    a, b = raw_input().split()

    print a if a == b else 1

#In the name of God

a,b = map(int, raw_input().split())

if a == b:
  print a
else:
  print 1

a,b=map(int,input().split(" "))
if a==b:
    print(a)
else:
    print(1)

a,b = [int(x) for x in raw_input().split()]
print a if a == b else 1

num = map(int, raw_input().split(' '))
num1, num2 = num[0], num[1]
resto = num1 % num2
if num2 - num1 >= 1:
    print 1
else:
    while (resto != 0):
        num1 = num2
        num2 = resto
        resto = num1 % num2
    print num2

num = map(int, raw_input().split(' '))
num1, num2 = num[0], num[1]
resto = num1 % num2
if num2 - num1 < 1:
    while (resto != 0):
        num1 = num2
        num2 = resto
        resto = num1 % num2
    print num2

else:
    print 1

a, b = list(map(str, input().split()))

if a == b:
    print(a)
else:
    print(1)

a,b = map(int,input().split())

if a == b:
  print(a)
else:
  print(1)

#print("muri")
a, b = map(str, input().split())
if a==b:print(a)
else: print("1")

#print("muri")
a, b = map(int, input().split())
if a==b:print(a)
else: print("1")

[a1,b1]=[int(x) for x in input().split(' ')]

if max(a1,b1) - min(a1,b1)> 0:
    print(1)
else:
    print(min(a1,b1))

import math

a, b = map(int, input().split())
r = a
for i in range(a+1, b+1):
    if r == 1:
        break
    r = math.gcd(r, i)
print(r)

# coding: utf-8

def mdc(a, b):

	if a == b:
		return a

	else:
		return 1

ent = raw_input().split()

print mdc(int(ent[0]), int(ent[1]))

s = input();
a,b = s.split();
a=int(a);
b=int(b);
def gcd(a,b) :
    if a%b==0 :
        return b;
    elif b%a==0 :
        return a;
    elif a>b :
        return gcd(a%b,b);
    elif a<b :
        return gcd(b%a,a);
ans=a;
for i in range(a+1,b+1) :
    ans =  gcd(ans,i);
    if ans==1 :
        break;
print(int(ans));

a, b = input().split()

if a == b:
    print(a)
else:
    print(1)

string = input()
a, b = map(int, string.split())
n = a
for x in range(a + 1, b + 1):
    a, b = x, n
    while a != 0 and b != 0:
        a %= b
        if a == 0:
            break
        b %= a
    if a == 0:
        n = b
    else:
        n = a
    if n == 1:
        break
print(n)

import fractions

a, b = map(int, raw_input().split())
if a == b:
    print a
else:
    print 1

def mdc(n1,n2):
	if n2 == 0:
		return n1
	return mdc(n2,n1%n2)

a,b = map(int,input().split())
if a >= b:
	print(mdc(a,b))
else:
	print("1")

a, b = [i for i in input().split()]

if a==b:
    print(a)
else:
    print(1)

x,y = map(int,input().split())

if x != y:
    print(1)
else:
    print(x)

a,b=map(int,input().split())
if(a==b):
    print(a)
else:
    print(1)

a, b=map(int, input().rstrip().split())
if a==b:
    print(a)
else:
    print(1)

a,b = list(map(int, input().strip().split(' ')))
mmin=a

if a==b :
	print(a)
else :
	print(1)

a,b=map(int,input().split())
if a==b:
    print(a)
else:
    print(1)

n,m = input().split()
if n == m:
    print(n)
else:
    print(1)

a, b = list(map(int, input().split()))
if a == b: print(a)
else: print("1")

a, b = input().split()
print(1 if a != b else a)

'__author__'=='deepak Singh Mehta(learning to code :) ) '

'''
    Hard work beats Talent when Talent doesn't work hard. :)
'''

if __name__=='__main__':
    a,b = map(int,input().split())
    if a==b:
        print(a)
    else:
        print(1)

a,b=map(int,input().split())
print(1 if abs(a-b)!=0 else a)

import math
a, b = map(int,input().split())
if a == b:
	print(a)
else:
	print(1)

a , b = map(int,input().split())

if a == b :
    print(a)

else:
    print(1)

from sys import stdin,stdout
input=lambda:stdin.readline().strip()
a,b=input().split()
if a==b:
    print(a)
else:
    print(1)

a, b=map(str, input().split())
if a==b:print(b)
else:print("1")

from math import gcd

a, b = map(int, input().split())

nod = gcd(a, b)
for i in range(a+1, b):
    nod = gcd(i,nod)
    if nod ==1:
        break

print(nod)

a, b = map(int, input().split())
if a == b:
    print(a)
else:
    print(1)

a, b = [int(x) for x in input().split()]
if a == b:
    print(a)
else:
    print(1)

inp = input().split(" ")
a=inp[0]
b=inp[1]
if(a==b):
    print (a)
else:
    print (1)

a,b=[int(i) for i in input().split()]
if a==b:print(a)
else:print(1)

s,z = map(int,input().split())
if s != z: print(1)
else: print(s)

def solution(l1):
    if l1[0]==l1[1]:
        return l1[0]
    else:
        return 1
def answer():
    l1 = [int(x) for x in input().split()]
    print(solution(l1))
answer()

a,b=input().split()
if a==b:
    print(a)
else:
    print(1);

import math

n = input()
n = n.split()
s = eval(n[0])
n = eval(n[1])

if n == s:
    print(n)

else:
    print(1)

a=raw_input()
a=a.split(' ')
b=int(a[1])
a=int(a[0])
if a==b or b%a==0 :
    if a==b or a+1==b:
        print a
    else:
        print 1
elif a<b:
        print 1

a, b = map(int, raw_input('').split(" "))

if a == b:
	print a
else:
	print 1

inputa = input();
linputa = inputa.split();
a = int(linputa[0]);
b = int(linputa[1]);
if(a-b):
    print(1);
else:
    print(a);

S = raw_input()
K= S.split(' ')
x = int(K[0])
y = int(K[1])

if x==y:
    print x
else:
    print '1'

a=raw_input().split()
if a[0]==a[1]:
	print a[0]
else:
	print 1

import os

xlist = raw_input().split()
if xlist[0] == xlist[1]:
	print xlist[0]
else:
	print '1'

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
s=raw_input()
a,b=s.split(' ')
a=int(a)
b=int(b)
if a==b:
    print a
else:
    m=gcd(a,a+1)
    i=a+2
    while(i<=b):
        if m==1: break
        m=gcd(m,i)
        i+=1
    print m

a,b=map(int,raw_input().split(' '))
if a==b:
    print a
else:
    print "1"

a, b = map(int,raw_input().split())
print a if (a==b) else 1

# -*- coding:utf-8 -*-
import fractions
a,b=map(int,raw_input().split(' '))
print 1 if a!=b else b

hello = raw_input().split()
first = int(hello[0])
second = int(hello[1])
if first == second:
	print first
else:
	print 1

x, y = raw_input().split()
if x == y:
	print x
else:
	print 1

num1, num2 = raw_input().split()
if num1 == num2:
    print num1
else:
    print 1

import sys

(a, b) = tuple(long(i) for i in sys.stdin.readline().strip().split())

if a == b:
    print a
else:
    print 1

a, b = map(int, raw_input().split())

if a != b: print 1
else: print a

a, b = map(int, raw_input().split())
if a != b:
	print 1
else:
	print a
	#rs

numbers = list(map(int,input().split()))

if (numbers[0] == numbers[1]):
    print(numbers[0])
else:
    print(1)

a,b = map(int,input().split())

if abs(a-b)>0:
    print(1)
else:
    print(a)

#encoding: utf-8

n2 = map(int, raw_input().split())
if (n2[0] == n2[1]):
	print n2[0]
else:
	print 1

#-*- encoding: utf-8 -*-
import sys
a, b = map(long, sys.stdin.readline().split());
if a == b:
    print a
else:
    print 1

a,b=map(int,raw_input().split())
if(a==b):
  print(a)
else:
  print(1)

def gcd(a,b):
	if b==0:
		return a
	else:
		return gcd(b,a%b)

a,b = map(int,input().split(" "))

print(str(gcd(a,b)))

a , b = map(int , input().split())

if a == 1 or b == 1:
    print(1)
elif a == b:
    print(a)

import math
a,b=map(int,input().split())
ans = 1
for i in range(a, b):
    ans = max(ans, math.gcd(i,b))
    if ans == 1:
        break
print(ans)

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

a,b=map(int,raw_input().split())
l=[a,b]
print gcd(max(l),min(l))

a, b = [int(n) for n in input().split()]

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

print(gcd(a, b))

inp = input().split()
a,b = int(inp[0]), int(inp[1])

while b!=0:
	t = b
	b = a%b
	a = t
print(a)

# your code goes here
a,b = input().split()

a = int(a)
b = int(b)

def gcd(a,b):
	if b==0:
		return a
	else:
		return gcd(b, a%b)

val = gcd(a,b)
print(val)

#never give up
x,y=map(int,input().split())
while(x!=y):
        if x>y:
                x-=y;
        else:
                y-=x;
print(x)

n,m=map(int,input().split())
def NOD(a,b) :
    while a!=0 and b!=0 :
        if a>b :
            a=a%b
        else :
            b=b%a
    return a+b
ma=0
for i in range(n,m+1) :
    ma=max(ma,NOD(i,m))
print(ma)

# cook your code here
def gcd(a,b):
                if(b==0):
                    return a;
                else:
                    return gcd(b,a%b);
numbers = map(int,raw_input().split())
if(numbers[0]>numbers[1]):
		myval=gcd(numbers[0],numbers[1]);
else:
		myval=gcd(numbers[1],numbers[0]);
print(myval);

from fractions import*
num1, num2 =  map(long, raw_input().split())
print gcd(num1, num2)

n,m=map(int,input().split())
i=m
while n*m:
    n%=m
    i=m
    m=n
    n=i
print(n)

a,b = list(map(int, input().strip().split(' ')))
while b!=0 :
	tmp=a;
	a=b;
	b=tmp%b;
print(a)

"""
from math import*
x = [True] * 1000100
x[1] = False
x[0] = False
for i in range(2, 1100):
	for j in range(2*i, len(x), i):
		x[j] = False
n = int(input())
a = map(int,input().split())
ans = []
for i in a:
	g = sqrt(i)
	if round(g) ** 2 != i:
		g = 100
	if x[int(g)] == True :
		ans.append("YES")
	ans.append("NO")
print('\n'.join(ans))
"""
"""
s1= input()
s2 = input()
glassn1 = 0
soglas1 = 0
glassn2 =0
soglas2=0
bulka = 0
if s1 == "abcdef" and s2 == "cdaebf":
	print("No")
	exit()
if s2 == s1[::-1] or s2[::-1] == s1:
	print("No")
	exit()
if len(s1) == len(s2):
	for i in range(len(s1)):
		if s1[i] in s2:
				bulka += 1
	if bulka == len(s1) or bulka == len(s2):
		print("No")
		exit()
for i in s1:
	if i == "a" or i == "e" or i == "i" or i == "o" or i == "u":
		glassn1 +=1
	else:
		soglas1+=1
for i in s2:
	if i == "a" or i == "e" or i == "i" or i == "o" or i == "u":
		glassn2 +=1
	else:
		soglas2+=1
if glassn1 == glassn2 and soglas1 == soglas2:
	print("Yes")
else:
	print("No")
"""
"""
s1 = input()
s2 = input()
glassn1 = "aeiou"
if len(s1) != len(s2):
    print("No")
else:
    for i in range(len(s1)):n = int()
        kek = s1[i] in glassn1
        lol = s2[i] in glassn1
        if kek != lol:
            print("No")
            exit()
    else:
        print("Yes")
"""

"""
c,n,f = map(int,input().split())
cows = ["*"]*c
keks = []
ind = 0
a = list(map(int,input().split()))
for i in range(f):
	p1,p2 = map(int,input().split())
	cows[p2-1] = p1
	for i in a:
		if i != p1:
			keks.append(i)
			break
	for i in range(len(keks)):
		cows[cows.index(p1)-1] = keks[i]
print(cows.index("*")+1,cows)
"""
"""

#Spichechnaya model
n = int(input())
kubik = 8
fkub = 12
for i in range(n-1):
	fkub += kubik
print(fkub)

"""

"""
#Dve okruznosti
x1,y1,r1,x2,y2,r2 = map(int,input().split())
if x1 == x2 and y1 == y2:
	print(-1)
elif x1 == x2 and y1 != y2:
	print(1)
else:
	print(2)
"""
"""
#Dva mnojitelya
n = int(input())
kek = []
for i in range(1,51+1):
	for j in range(i,51+1):
		kek.append(i*j)
print(kek[n])
"""
"""
#delitsya na 4 or 8 or 2?
n = int(input())
if n % 2 == 0:
   print("YES")
else:
   print("NO")
if n%4==0:
   print("YES")
else:
   print("NO")
if n % 8 == 0:
   print("YES")
else:
   print("NO")
"""
"""
n = int(input())
police = 0
ans = 0
a = list(map(int,input().split()))
for i in range(n):
		if a[i]<0 and police != 0:
			police -= 1
		elif a[i] < 0 and police == 0:
			ans += 1
		elif a[i]>0:
			police+=a[i]
print(ans)
"""
"""
#kek
n = int(input())
ans = 0
for i in range(n):
	a,b,c = map(int,input().split())
	if c % 2 == 0:
		print((c//2) * a - (c//2) * b)
	else:
		print((c//2+1)*a - (c//2*b))
"""
"""
n = int(input())
mx=[[]]
for i in range(n):
	mx[i] = list(map(int,input().split()))
kek = 0
for i in range(n):
    kek += mx[i][i]
    kek += mx[i][n-i-1]
    kek += mx[n//2][i]
    kek += mx[i][n//2]
kek -= 3*mx[n//2][n//2]
print(kek)
"""
"""
n = int(input())
for i in range(n):
	m = int(input())
	if m % 4 == 1:
		print("ALICE")
	else:
		print("BOB")
"""
"""
n = int(input())
lst = []
for i in range(n):
	f = input()
	s = input()
	t = input()
	if  f[0] == "l" and s[0] == "l" and t[0] == "l" and t[1] == "l"     or     f[0] == "l" and s[0] == "l" and t[0] == "l" and t[1] == "l" and t[2] == "l" or f[0] == "l" and s[0] == "l" and s[1]=="l" or  f[0] == "l" and s[0] == "l" and s[1]=="l" and s[2]=="l" or f[1]=="l" and s[1] == "l" and s[2] =="l" or f[1]=="l" and s[1] == "l" and t[1] == "l" and t[2] == "l" or s[1] == "l" and t[1]=="l" and t[2] == "l" or s[0] == "l" and t[0] =="l" and t[1] == "l" or s[0] == "l" and t[0] =="l" and t[1] == "l" and t[2] == "l":
		lst.append("yes")
	else:
		lst.append("no")
for i in lst:
	print(i)
"""
"""
n = int(input())
unbinar = ""
binar = []
for i in range(n):
	a,b=map(int,input().split())
	for i in range(a,b+1):
		binar.append(str(bin(i))[2:])
for i in range(len(binar)):
	if int(binar[i]) == 0 and int(binar[i-1]) == 0:
			unbinar+= "0"
	else:
			unbinar+="1"
print(unbinar)
"""
"""
from math import*
num,base = map(int,input().split())
zeros = 0
fnum = factorial(num)
if base < 2 or base > 10**18:
	exit()
newNum = ''
while fnum > 0:
    newNum = str(fnum % base) + newNum
    fnum //= base
rev = newNum[::-1]
i = 0;
while 1:
	if rev[i] == "0":
		zeros+=1
	else:
		break
	i += 1
print(zeros)

"""
"""
n = int(input())
lol = []
kek = n
if n > 0:
	print(n)
elif len(str(n)) == 3 and n < 0:
	print(str(n)[2])
"""
"""
c,n,f = map(int,input().split())
cows = ["*"]*c
keks = []
ind = 0
a = list(map(int,input().split()))
for i in range(f):
	p1,p2 = map(int,input().split())
	cows[p2-1] = p1
	for i in a:
		if i != p1:
			keks.append(i)
			break
	for i in range(len(keks)):
		cows[cows.index(p1)-1] = keks[i]
print(cows.index("*")+1,cows)
"""
"""
a,b = map(int,input().split())
tetr = list(map(int,input().split()))
per = []
for i in range(a):
	if tetr[i] < b:
		for i in range(tetr[i]):
			per.append(i)
			print(per)
"""
"""
a,b = map(int,input().split())
i = 1
while a != 0 or b != 0:
	a -= i
	i+=1
	b-=i
	if a == 0:
		print("Valera")
		break
	else:
		print("Vladik")
		break
"""
a,b = map(int,input().split())
if b % a == 0 and a != b:
	print (1)
else:
	print(min(a,b))

a, b = map(int, input().split())
import math

print(math.gcd(a, b))

def gcd(a, b):
    while a != b:
        if a > b:
            a -= b
        else:
            b -= a
    return a
def main():
    var1, var2 = [int(x) for x in raw_input().split()]
    print(gcd(var1,var2))
main()

n,m=map(int,input().split())
def NOD(a,b) :
    while a!=0 and b!=0 :
        if a>b :
            a=a%b
        else :
            b=b%a
    return a+b
print(NOD(n,m))

#Complicated GCD
from math import gcd
a,b = map(int,input().split())
li = []
if b-a >=50:
    ans = 1
else:
    for i in range(a,b+1):
        li.append(i)
    if len(li)==1:
        ans = li[0]
    else:
        for i in range(len(li)-1):
            ans = gcd(li[i],li[i+1])
            print(ans)
            if ans == 1:
                break
print(ans)

#coding: utf-8
entrada1 = list(map(int,raw_input().split()))

def mdc(a, b):
    while(a % b != 0):
        aux = b
        b = a % b
        a = aux
    return b

result = mdc(entrada1[0], entrada1[1])
print result

#como cigarras periodicas sqn

def gcd(a,b):
    if(a == 0): return b
    if(b == 0): return a
    return gcd(b,a%b)

#def cigarra():

a,b = [int(i) for i in input().split()]

print(gcd(a,b))

from math import gcd
x,y = map(int, input().split())
print (gcd(x,y))

a,b = list(map(int, input().split()))
if a==b:
	print(a)
elif b-a==1:
	print(1)
else:
	print(2)

a, b = map(int, raw_input().split())
# gcd(a, b) = gcd(b, a % b)
while b > 0:
    a, b = b, a % b
print a

hello = raw_input().split()
first = int(hello[0])
second = int(hello[1])
if first < second:
	c = first
	first = second
	second = c
while second >= 1:
	c = first % second
	first = second
	second = c
print first,'\n'

from fractions import gcd
a, b = map(int, input().split(' '))
print(gcd(a, b))

import sys

def euclid(a, b):
	if b > a:
		temp = a
		a = b
		b = temp
	assert a >= b
	r = a % b
	if r == 0:
		return b
	else:
		return euclid(b, r)

(a, b) = tuple(long(i) for i in sys.stdin.readline().strip().split())
print euclid(a, b)

import fractions
a, b = raw_input().split(' ')
a, b = long(a), long(b)
print fractions.gcd(a, b)

a,b=map(int,input().split())
i=min(a,b)
while i>=0:
    if a%i==0 and b%i==0:
        print(i)
        break
    i=i-1

def gcd(u, v):
    if (u == v):
        return u

    if (u == 0):
        return v

    if (v == 0):
        return u

    if (~u & 1):
        if (v & 1):
            return gcd(u >> 1, v)
        else:
            return gcd(u >> 1, v >> 1) << 1

    if (~v & 1):
        return gcd(u, v >> 1);

    if (u > v):
        return gcd((u - v) >> 1, v)

    return gcd((v - u) >> 1, u)

a, b = map(int, input().split(' '))
print(gcd(a, b))

n,m=map(int,input().split())
i=m
while n*m:
    n%=m
    i=m
    m=n
    n=i
print(n)

linha = map(int, raw_input().split())
while True:
    if linha[1] == 0:
        break
    linha.sort()
    linha[1] = linha[1] % linha[0]

print linha[0]

def gcd(a, b):
  while b > 0:
    a, b = b, a % b
  return a

a, b = map(int, raw_input().split())
print a if a == b else gcd(a, b)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b);
def main():
    var1, var2 = [long(x) for x in raw_input().split()]
    print(gcd(var1,var2))
main()

a , b = map(int , input().split())

if a == 1 or b == 1:
    print(1)
elif a == b:
    print(a)

def gcd(a, b):
  if a % b != 0:
    return gcd(b, a % b)
  return b

if __name__ == '__main__':
  a, b = [int(i) for i in input().split()]
  print(gcd(a, b))

inp = input()
a=inp[0]
b=inp[1]
if(a==b):
    print (a)
else:
    print (1)

n,m=map(int,input().split())
i=0
while n*m:
    n%=m
    i=m
    m=n
    n=i
print(n)

a,b = map(int, raw_input().split())

if a != b:
    print 1
else:
    print 0

import sys
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
a,b = map(int,input().split())
print(gcd(a,b))

import sys
def gcd(a, b):
    if a%b == 0:
        return b
    return gcd(b, a%b)
a,b = map(int,input().split())
print(gcd(a,b))

# -*- coding:utf-8 -*-
#[n, m] = [int(x) for x in raw_input().split()]

def some_func():
    """
    """
    a, b= [int(x) for x in raw_input().split()]
    print a

if __name__ == '__main__':
    some_func()

def gcd(a, b):
    if b==0:
        return a
    a, b = b, a%b
    return gcd(a, b)

a,b = [int(x) for x in input().split()]

if a<b:
    a,b = b,a

print(gcd(a,b))

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# GCD -- START --
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
# GCD --- END ---

def main():
  n,m=LI()
  return gcd(n,m)

# main()
print(main())

from fractions import gcd

inp = raw_input()

arr = inp.split(' ')

n1 = int(arr[0])
n2 = int(arr[1])

ans = n1

# for x in range(n1,n1+1):
# 	ans = gcd(ans,x)
# 	pass

# print arr[0],"\n\n",arr[1],"\n\n"

print 1

a,b=map(int,input().split())
while a!=b:
    if a>b: a-=b
    else : b-=a
print(a)

def GCD(n,m):
    if m==0:
        return n
    else:
        return GCD(m,n%m)
a,b = map (int,raw_input().split())
print GCD (a,b)

import fractions

def gcd(*values):
    return reduce(fractions.gcd, values)
a,b=raw_input().split()
a=int(a)
b=int(b)
ans=b

print gcd(range(a,b+1))[0]

a, b = (int(n) for n in raw_input().split())
if a == b:
    print a
else:
    print b

def gcd(a,b):
    if b > a:
        return gcd(b,a)
    r = a%b
    if r == 0:
        return b
    return gcd(r,b)
a, b= [int(i) for i in input().split()]
print(gcd(a,b))

import math
f=lambda:map(int,input().split())
a,b=f()
print(math.gcd(a,b),end='')

def gcd(a,b):
	while(a!=b):
		if(a>b):
			a-=b
		else:
			b-=a;
	return a
a,b=map(int,input().strip().split())
print(gcd(a,b))

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

a,b = input().split()
a=int(a)
b=int(b)
print(gcd(a, b))

def gcd(a,b):
    if a==0:
        return b
    return gcd(b%a,a)

t=list(map(int,input().split()))
print(gcd(t[0],t[1]))

import math
a,b=map(int,input().split())
print(math.gcd(a,b))

a, b = [int(x) for x in raw_input().split()]

while a != 0 and b != 0:
    if a > b:
        a = a % b
    else:
        b = b % a

print a + b

import sys
a,b=map(int,raw_input().split())
if b-a>1:
	print 1
else:
	print a

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
def main():
    a,b=map(int,input().split(" "))
    a,b=max(a,b),min(a,b)

    print(gcd(a,b))
main()

import math
from fractions import gcd

line = raw_input()
line = line.split(' ')

a = int(line[0])
b = int(line[1])

max_gcd = 0
g = b;
for i in range(b-1, a-1, -1):
    g = gcd(g, i)
    if g > max_gcd:
        max_gcd = g

print max_gcd

n,m=map(int,input().split())
i=0
while n*m:
    n%=m
    i=m
    m=n
    n=i
print(n)

from math import gcd
a,b = map(int,input().split())

print(gcd(a,b))

a, b = [int(n) for n in input().split()]

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

print(gcd(b, a))

from sys import stdin,stdout
# stdin = open("/home/shiva/Learning/1.txt", "r")
# stdout = open("/home/shiva/Learning/2.txt", "w")
def gcd(a,b):
	if b==0:
		return a
	return gcd(b,a%b)

a,b = stdin.readline().split()
stdout.write(str(gcd(int(a),int(b))))

import math
a, b = map(int, input().split())
print(math.gcd(a, b))

a=str(input()).split()
x=max(int(a[0]),int(a[1]))
y=min(int(a[1]),int(a[1]))
def bacot(m, n):
       if n==0:
              return m
       else:
              return bacot(n, m%n)
xx=bacot(x, y)
print(xx)

a, b = map(int, input().split())
if a>b:
    print(1)

else:
    print(a)

from fractions import gcd
a, b = map(int, input().split(' '))
print(gcd(a, b))

s = 1

def gcd(a, b):
	if b == 0:
		return a
	else :
		return gcd(b, a % b)

p, q = map(int, raw_input().split(' '));

print gcd(p, q)

a,b=map(int,input().split())
if a-b==1 or a-b==-1:
    print(1)
if a==b:
    print(a)
if a==1 or b==1:
    print(1)

numbers = list(map(int, input().split()))
a=numbers[0]
b=numbers[1]
maxi=1
for i in range (a,1):
	found=true
	for x in range (a,b):
		if x%i!=0:
			found=false
	if found:
		maxim=i

print (maxi)

linha = map(int, raw_input().split())
while linha != 1:
	if linha[1] == 0: break
	linha.sort()
	linha[1] = linha[1] % linha[0]

print linha[0]

def gcd(a, b):
    if a < 0 or b < 0:
        return 0
    c = 0
    while b != 0:
        c = a%b
        a = b
        b = c
    return a
def main():
    var1, var2 = [int(x) for x in raw_input().split()]
    print(gcd(var1,var2))
main()

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
x, y = map(int, input().split())
print(gcd(x, y))

import sys

def gcd(x,y):
    if x==0:
    	return y
    else:
    	return gcd(y%x,x)

n,k=sys.stdin.readline().split(" ")
n=int(n)
k=int(k)
print gcd(n,k)

a,b=map(int,input().split())
i=a
while i>0:
    if a%i==0 and b%i==0:
        print(i)
        break
    i-=1

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

a, b = [int(i) for i in input().split(' ')]

print(gcd(a, b))

a,b = list(map(int, input().split()))
if a==b:
	print(a)
elif b-a==1:
	print(1)
else:
	print(2)

def gcd(a, b):
    while b:
       a, b = b, a%b
    return a

numbers = list(map(int,input().split()))

print(gcd(numbers[0],numbers[1]))

def gcd(a, b):
    if b == 0:
       return a
    else:
       return gcd(b, a % b)

a, b = [int(i) for i in input().split()]
print(gcd(a, b))

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

a,b=map(int,raw_input().split())
print gcd(a,b)

import math
a,b=map(int,input().split())
print(math.gcd(a,b))

import sys
a,b=map(int,raw_input().split())
if b-a>1:
	print 1
else:
	print a


n, ans, x = input (), 0, [0 for i in xrange (9)]
for i in xrange (1, n + 1):
    ans -= n / i
    x[i % 9] += 1
for i in xrange (9):
    for j in xrange (9):
        ans += x[i] * x[j] * x[(i * j) % 9]
print ans

from math import sqrt, floor

n = int(input())

true_products, a = 0, 1

while a ** 2 <= n:
	true_products += n // a - a
	a += 1

true_products *= 2

true_products += floor(sqrt(n))

digit_roots = [n // 9 for _ in range(9)]
for i in range(1, n % 9 + 1):
	digit_roots[i] += 1

digit_root_products = 0

for i in range(9):
	for j in range(9):
		digit_root_products += digit_roots[i] * digit_roots[j] * digit_roots[(i * j) % 9]

print(digit_root_products - true_products)

n , ans , a = int(input()) , 0 , [0] * 10
for i in range(1,n+1):
    ans -= (int)(n/i)
    a[i % 9] += 1
for i in range(9):
    for j in range(9):
        ans += a[i] * a[j] * a[(i * j) % 9]
print (ans)

__author__ = 'Darren'

# d(x) = (x-1) % 9 + 1

def solve():

    n = int(input())

    # count[i]: the number of x's in [1,n] such that d(x) = i

    count = [0] * 10

    for i in range((n-1) % 9 + 2):

        count[i] = (n + 8) // 9

    for i in range((n-1) % 9 + 2, 10):

        count[i] = n // 9

    result = 0

    # Count all triples (i, j, k) such that d(d(i)*d(j)) = d(k)

    for i in range(1, 10):

        for j in range(1, 10):

            result += count[i] * count[j] * count[(i*j-1) % 9 + 1]

    # For each i, there are n/i triples (i,j,k) such that i*j = k,

    # i.e., the correct cases

    for i in range(1, n+1):

        result -= n // i

    print(result)

if __name__ == '__main__':

    solve()

# Made By Mostafa_Khaled

n = int(raw_input())
count = [0] * 10
for idx in range(1, n+1):
    count[idx%9] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += count[i] * count[j] * count[i*j%9]

for i in range(1, n+1):
    ans -= n / i

print ans

n,a,c=input(),0,[0]*10
for x in range(1,n+1):
  a-=n/x
  c[x%9]+=1
for i in range(9):
  for j in range(9):
    a+=c[i]*c[j]*c[i*j%9]
print a

import math

def f(n, r):
    if r > n:
        return 0
    if r == 0:
        return (n - r) / 9
    else:
        return (n - r) / 9 + 1

def test_f(n):
    s = sum(map(lambda r: f(n, r), range(0, 9)))
    print "Testing", n, '?=', s
    assert (n == s)

n = int(raw_input())

#test_f(n)

N0 = 0
# for i in range(1, int(math.sqrt(n)) + 1):
for i in range(1, n + 1):
#    print i, ':', n / i
    N0 += n / i

F = 0
for i in range(0, 9):
    for j in range(0, 9):
        F += f(n, i) * f(n, j) * f(n, (i * j) % 9)

#print F, '-', N0, '=',
print F - N0

def digRoot(n): return 9 if n % 9 == 0 else n % 9

n = int(raw_input())
good = 0
for i in range(1, n + 1):
    temp = n // i
    good += temp

all = 0
for a in range(1, 10):
    for b in range(1, 10):
        c = digRoot(a * b)
        all += ( (n + 9 - a) // 9 ) * ( (n + 9 - b) // 9 ) * ( (n + 9 - c) // 9 )

print(all - good)

def root(a):
    res = 0
    while a>0:
        res+=a%10
        a/=10
    return root(res) if res>9 else res

n = int(raw_input())
rt = [root(i) for i in xrange(0,100)]
root
sum = 1
t = [0 for i in xrange(0,10)]
for i in xrange(1,n+1):
    t[rt[sum]]+=1
    #print i,sum
    sum+=1
    if (i%10) == 9:
        sum-=9
        if (i%100)==99:
            sum-=9
            if (i%1000)==999:
                sum-=9
                if (i%10000)==9999:
                    sum-=9
                    if (i%100000)==99999:
                        sum-=9
                        if (i%1000000)==999999:
                            sum-=9
ans1 = 0
#print rt
#print t
for r1,i in enumerate(t):
    for r2,j in enumerate(t):
        for r3,k in enumerate(t):
            if r3==root(r2*r1):
                #if i*j*k>0 : print r1,r2,r3
                ans1+=i*j*k
ans2 = 0
for i in xrange(1,n+1):
    ans2+=n/i
#print [(i,j) for (i,j) in enumerate(t)]
#print root(1)
#print ans1
print ans1-ans2

n = int(raw_input())
d = [(n-i)/9+1 for i in range(1,10)]
s = 0
for i in range(1,10):
	for j in range(1,10):
		s += d[i-1]*d[j-1]*d[(i*j-1)%9]
sqn = int(n**0.5)
for i in range(1,sqn+1):
	s -= (n/i-i)*2+1
print s

import sys

def g(n):
    g = [n/9+1]*(n%9)+[n/9]*(9-n%9)
    g = g[-1:]+g[:-1]
    f = [0]*9
    for i in range(9):
        for j in range(9):
            f[(i*j)%9] += g[i]*g[j]
    r = sum([f[i]*g[i] for i in range(9)])
    for i in range(1,n+1):
        r -= n/i
    return r

print "%d" % g(int(sys.stdin.readline()))

from math import sqrt
N=input()
d=[(N-i)/9+1 for i in range(1,10)]
s=0
for i in range(1,10):
        for j in range(1,10):
                s+=d[i-1]*d[j-1]*d[(i*j-1)%9]
sqrtN=int(sqrt(N))
for i in range(1,sqrtN+1):
        s-=(N/i-i)*2+1
print s

n = input()
r = xrange(9)
a = [n / 9 + (1 <= i <= n % 9) for i in r]
print sum(a[i] * a[j] * a[i * j % 9] for i in r for j in r) - sum(n / i for i in xrange(1, n + 1))

p,u,d=input(),0,[0]*10
for g in range(1,p+1):
  u-=p/g
  d[g%9]+=1
for i in range(9):
  for j in range(9):
    u+=d[i]*d[j]*d[i*j%9]
print u

n = int(raw_input())
s = 0
c = [0]*9
for i in range(1, n + 1):
	s -= n / i
	c[i % 9] = c[i % 9] + 1
for i in range(9):
	for j in range(9):
		s += c[i] * c[j] * c[i * j % 9]
print s

n = int(raw_input())
ans = 0
cnt = [0]*9
for i in xrange(1, n+1):
    ans -= n/i
    cnt[i%9] += 1;
for i in xrange(9):
    for j in xrange(9):
        ans += cnt[i]*cnt[j]*cnt[i*j%9]
print ans

ll = [0]
for i in range(1,101):
    d = i
    while d >= i:
        tmp = 0
        while d > 0:
            tmp += d%10
            d /= 10
        d = tmp
        if d < 10: break
    if d < 10:
        ll.append(d)
    else:
        ll.append(ll[d])

n = int(raw_input())
num = [0]
for i in range(1,10):
    num.append(0)
    if n%9 >= i:
        tmp = 1
    else:
        tmp = 0
    num[i] = n/9 + tmp

ret = 0
for i in range(1,10):
    for j in range(1,10):
        for k in range(1,10):
            if ll[i*j] == ll[k]:
                ret += num[i]*num[j]*num[k]

for i in range(1,n+1):
    ret -= n/i
print ret

ll = [0]
for i in xrange(1,101):
    d = i
    while d >= i:
        tmp = 0
        while d > 0:
            tmp += d%10
            d /= 10
        d = tmp
        if d < 10: break
    if d < 10:
        ll.append(d)
    else:
        ll.append(ll[d])

n = int(raw_input())
num = [0]
for i in xrange(1,10):
    num.append(0)
    if n%9 >= i:
        tmp = 1
    else:
        tmp = 0
    num[i] = n/9 + tmp

ret = 0
for i in xrange(1,10):
    for j in xrange(1,10):
        for k in xrange(1,10):
            if ll[i*j] == ll[k]:
                ret += num[i]*num[j]*num[k]

for i in xrange(1,n+1):
    ret -= n/i
print ret

n,ans,ref=input(),0,[0]*10
for i in range(1,n+1):
  ans -= n/i
  ref[i%9] += 1
ans += sum([ref[i]*ref[j]*ref[i*j%9] for j in range(9) for i in range(9)])
print ans

n = int(input())
c = [0] * 9
ans = 0
for i in range(1, n + 1):
    ans -= n // i
    c[i % 9] += 1
for i in range(9):
    for j in range(9):
        ans += c[i] * c[j] * c[i * j % 9]
print(ans)

def main():
    ans = 0
    a = [0] * 10
    n = int(input())
    for i in range (0, 9):
        a[i] = n // 9 + int(n % 9 >= i)
    a[0] -= 1

    for i in range(0, 9):
        for j in range(0, 9):
            k = i * j % 9
            ans += a[i] * a[j] * a[k]

    for i in range(1, n + 1):
        ans -= n // i
    print(ans)

    return

if __name__ == "__main__":
    main()

def main():
    ans = 0
    a = [0] * 10
    n = int(input())
    for i in range (1, 9):
        a[i] = n // 9 + int(n % 9 >= i)
    a[9] = n // 9

    for i in range(1, 10):
        for j in range(1, 10):
            k = i * j % 9
            if k == 0:
                k = 9
            ans += a[i] * a[j] * a[k]

    for i in range(1, n + 1):
        ans -= n // i
    print(ans)

    return

if __name__ == "__main__":
    main()

n = int(input())
corr = 0
for i in range(1, n + 1):
    corr += (n // i)

total = 0

count = [0] * 9
for i in range(1, n + 1):
    count[i % 9] += 1

mult = [0]*9
for i in range(9):
    for j in range(9):
        mult[(i * j) % 9] += count[i] * count[j]

for i in range(9):
    total += mult[i] * count[i]

print(total - corr)

n, ans, a = int(input()), 0, [0] * 10
for i in range(1, n + 1):
    ans -= int(n/i)
    a[i % 9] += 1
for i in range(9):
    for j in range(9):
        ans += a[i] * a[j] * a[(i * j) % 9]
print(ans)

n = int(raw_input())
count = [0] * 10
for idx in range(1, n+1):
    count[idx%9] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += count[i] * count[j] * count[i*j%9]

print ans
for i in range(1, n+1):
    for j in range(i, n+1, i):
        ans -= 1

print ans

n = int(raw_input())
count = [0] * 10
for idx in range(1, n+1):
    count[idx%9] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += count[i] * count[j] * count[i*j%9]

for i in range(1, n+1):
    for j in range(i, n+1, i):
        ans -= 1

print ans

def main():
    ans = 0
    a = [0] * 10
    n = int(input())
    for i in range (1, 9):
        a[i] = n // 9 + int(n % 9 >= i)
    a[9] = n // 9

    for i in range(1, 10):
        for j in range(1, 10):
            k = i * j % 9
            if k == 0:
                k = 9
            ans += a[i] * a[j] * a[k]

    for i in range(1, n):
        ans -= n // i
    print(ans)

    return

if __name__ == "__main__":
    main()