Vasya likes to solve equations. Today he wants to solve $(x~\mathrm{div}~k) \cdot (x \bmod k) = n$, where $\mathrm{div}$ and $\mathrm{mod}$ stand for integer division and modulo operations (refer to the Notes below for exact definition). In this equation, $k$ and $n$ are positive integer parameters, and $x$ is a positive integer unknown. If there are several solutions, Vasya wants to find the smallest possible $x$. Can you help him?


-----Input-----

The first line contains two integers $n$ and $k$ ($1 \leq n \leq 10^6$, $2 \leq k \leq 1000$).


-----Output-----

Print a single integer $x$ — the smallest positive integer solution to $(x~\mathrm{div}~k) \cdot (x \bmod k) = n$. It is guaranteed that this equation has at least one positive integer solution.


-----Examples-----
Input
6 3

Output
11

Input
1 2

Output
3

Input
4 6

Output
10



-----Note-----

The result of integer division $a~\mathrm{div}~b$ is equal to the largest integer $c$ such that $b \cdot c \leq a$. $a$ modulo $b$ (shortened $a \bmod b$) is the only integer $c$ such that $0 \leq c < b$, and $a - c$ is divisible by $b$.

In the first sample, $11~\mathrm{div}~3 = 3$ and $11 \bmod 3 = 2$. Since $3 \cdot 2 = 6$, then $x = 11$ is a solution to $(x~\mathrm{div}~3) \cdot (x \bmod 3) = 6$. One can see that $19$ is the only other positive integer solution, hence $11$ is the smallest one.

Difficulty: EASY

Solutions:
(n, k) = map(int, input().split())
d = k - 1
while d >= 1:
	z = n / d
	if z - n // d == 0:
		print(n // d * k + d)
		break
	d -= 1


(n, k) = map(int, input().split())
i = 0
y = k - 1
while i == 0:
	if n % y == 0:
		m = n // y
		i = 1
	else:
		y -= 1
x = m * k + y
print(x)


import math
x4 = float('inf')
(n, k) = map(int, input().split())
for d1 in range(1, math.trunc(n ** 0.5) + 1):
	if n % d1 == 0:
		d2 = n / d1
		if (d1 * k + d2) // k * ((d1 * k + d2) % k) == n:
			x1 = d1 * k + d2
		else:
			x1 = float('inf')
		if (d2 * k + d1) // k * ((d2 * k + d1) % k) == n:
			x2 = d2 * k + d1
		else:
			x2 = float('inf')
		x3 = min(x1, x2)
		x4 = min(x3, x4)
print(math.trunc(x4))


(n, k) = [int(x) for x in input().split()]
tot = []
for item in range(1, k):
	x = (n * k + item ** 2) / item
	if x // k == n / item:
		tot.append(x)
print(int(sorted(tot)[0]))


(n, k) = map(int, input().split())
for m in reversed(range(k)):
	if not n % m:
		break
print(n * k // m + m)


import math

def div(n):
	sq = int(math.sqrt(n)) + 1
	a = []
	for i in range(1, sq):
		if n % i == 0:
			a.append(i)
	return a
(n, k) = map(int, input().split())
a = div(n)
x = 100000000000000
for i in a:
	j = n // i
	s = k * i
	z = s + j
	if z // k == i and z % k == j:
		x = min(x, z)
	s = k * j
	z = s + i
	if z // k == j and z % k == i:
		x = min(x, z)
print(x)


(n, k) = map(int, input().split())
for i in range(1, n + 1):
	if n % i == 0:
		if n // i < k:
			print(k * i + n // i)
			break


(n, k) = map(int, input().split())
r = int(1000000000.0)
for i in range(1, k):
	if n % i < 1:
		r = min(r, n * k // i + i)
print(r)


s = input()
lista = s.split(' ')
n = int(lista[0])
k = int(lista[1])
ans = 1000000000.0
for x in range(1, k):
	if n % x == 0:
		m = n // x
		if ans >= m * k + x:
			ans = m * k + x
print(ans)


data = list(map(int, input().split(' ')))
temp = 0
po = []
mul = data[0]
num = data[1]
for i in range(1, num):
	if mul % i == 0:
		po.append(i + num * mul // i)
print(sorted(po)[0])


(n, k) = map(int, input().split())
l = 1
while True:
	if n % l == 0:
		mod = n // l
		if mod >= 1 and mod <= k - 1:
			print(l * k + mod)
			break
	l += 1


(n, k) = map(int, input().split())
for p in range(k - 1, 0, -1):
	x = int(n * k / p + p)
	if x // k * (x % k) == n:
		print(int(x))
		break


(n, k) = map(int, input().split())
x = k - 1
while n % x:
	x -= 1
print(n // x * k + x)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
(n, k) = mi()
d = sorted(divs(n))
for item in d:
	if item < k:
		c = item
print(c + k * (n // c))


(n, k) = map(int, input().split())
mods = [i for i in range(1, k)]
divs = []
for i in mods:
	if n % i == 0:
		divs.append((n // i, i))
mas = []
for i in divs:
	if i[0] * i[1] == n:
		mas.append(i[0] * k + i[1])
print(min(mas))


import math
(n, k) = map(int, input().split())
divs = [(d, n // d) for d in range(1, int(math.sqrt(n)) + 1) if n % d == 0]
ans = []
for d in divs:
	if d[1] < k:
		ans.append(d[0] * k + d[1])
	if d[0] < k:
		ans.append(d[1] * k + d[0])
print(min(ans))


(n, k) = [int(s) for s in input().split()]
for i in range(k - 1, 0, -1):
	if n % i == 0:
		print(n // i * k + i)
		exit(0)


(n, k) = map(int, input().split())
inf = n / k
best = inf ** 1 / 2

def calb(x):
	global k
	global n
	return x * k + n // x

def check(x):
	global n
	global sup
	if x != 0 and n % x == 0 and (x > inf):
		return True
	else:
		return False
if best <= inf:
	i = -(-inf // 1)
	while 1 - check(i):
		i += 1
	else:
		print(calb(int(i)))
		quit()
else:
	a = []
	for i in range(int(best) + 1, -(-inf // 1), -1):
		if check(i):
			a.append(i)
			break
	i = int(best) + 1
	while len(a) == 0 or calb(i) < a[0]:
		if check(i):
			a.append(calb(i))
			break
		i += 1
print(min(a))


(n, k) = map(int, input().split())
i = 1
while True:
	if n % (k - i) == 0:
		print(n // (k - i) * k + k - i)
		break
	i += 1


(n, k) = list(map(int, input().split()))
a = k - 1
while a > 0:
	if n % a == 0:
		print(a + n // a * k)
		break
	a -= 1


import sys
(n, k) = map(int, sys.stdin.readline().split())
res = []
for i in range(1, k):
	if int(n / i) == n / i:
		res.append(k * int(n / i) + i)
print(min(res))


(n, k) = map(int, input().split())
ans = 99999999999999999999999999999999999
for i in range(1, k):
	if n % i == 0:
		ans = min(ans, n // i * k + i)
print(ans)


(n, k) = map(int, input().split())
r = k - 1
while n % r != 0:
	r -= 1
m = n // r
x = k * m + r
print(x)


from sys import stdin
from math import sqrt

def r():
	return stdin.readline().strip()

def r_t(tp):
	return map(tp, r().strip().split())

def r_l(tp):
	return list(r_t(tp))

def divides(a, b):
	return abs(b / a - b // a) < 1e-07

def divisors(n):
	ans = []
	for i in range(1, int(sqrt(n)) + 1):
		if divides(i, n):
			ans.append(i)
			if n // i != i:
				ans.append(n // i)
	return ans

def solve(n, k):
	D = divisors(n)
	D.sort()
	for d in D:
		for x in range(d * k + 1, d * k + k):
			if x // k * (x % k) == n:
				return x

def main():
	(n, k) = r_t(int)
	print(solve(n, k))
main()


(n, k) = map(int, input().split())
z = 0
for i in range(1, k):
	if n % i == 0:
		ans = n // i * k + i
		if z == 0:
			m = ans
			z = 1
		elif m > ans:
			m = ans
print(m)


(n, k) = map(int, input().split())
a = []
for i in range(1, k):
	if n % i == 0:
		a.append(n // i * k + i)
print(min(a))


(n, k) = map(int, input().split())
q = 0
w = k
while q == 0:
	w -= 1
	if n % w == 0:
		q = n // w
print(q * k + w)


(a, b) = input().split()
a = int(a)
b = int(b)
for i in reversed(range(b)):
	if a % i == 0:
		print(int(a * b / i + i))
		break


def seek(n, k):
	o = 10 ** 18
	for i in range(1, n + 1):
		if n % i == 0:
			a = n // i
			x = k * i + a
			if x // k * (x % k) == n:
				o = min(o, x)
				continue
			x = k * a + i
			if x // k * (x % k) == n:
				o = min(o, x)
	return o
(n, k) = map(int, input().split())
print(seek(n, k))


temp = list(map(int, input().strip().split()))
(n, k) = (temp[0], temp[1])
minn = 2147483647
for r in range(1, k):
	if n % r == 0:
		x = k * n / r + r
		if x < minn:
			minn = x
print(int(minn))


(n, k) = map(int, input().split())
dels = []
for i in range(1, k):
	if n % i == 0:
		dels.append(i)
dels.sort(reverse=True)
minn = 10 ** 9
for j in dels:
	for i in range(k):
		x = n // j * k + i
		if x % k == j:
			minn = min(x, minn)
print(minn)


import sys
(n, k) = input().split()
n = int(n)
k = int(k)
import math

def divisors(n):
	divs = [1]
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			divs.extend([i, n / i])
	divs.extend([n])
	return list(set(divs))
z = divisors(n)
for i in range(len(z)):
	z[i] = int(z[i])
s = []
for i in range(len(z)):
	for j in range(i, len(z)):
		if z[i] * z[j] == n:
			s.append([z[i], z[j]])
ans = []
z2 = []
z3 = []
for i in range(len(s)):
	z2.append(s[i][0] * k)
	z3.append(s[i][1] * k)
for i in range(len(z2)):
	f = 0
	while z2[i] % k != s[i][1] and f < k:
		z2[i] += 1
		f += 1
	if z2[i] % k == s[i][1]:
		ans.append(z2[i])
for i in range(len(z3)):
	f = 0
	while z3[i] % k != s[i][0] and f < k:
		z3[i] += 1
		f += 1
	if z3[i] % k == s[i][0]:
		ans.append(z3[i])
print(min(ans))


(n, k) = map(int, input().split())
m = 10000000000000000000
for i in range(1, k):
	if n % i == 0:
		x = i + k * (n // i)
		if m > x:
			m = x
print(m)


from math import sqrt

def func():
	(n, k) = map(int, input().split())
	for b in range(k - 1, 0, -1):
		(p, q) = divmod(n, b)
		if q == 0:
			x = p * k + b
			return x
print(func())


d = list(map(int, input().split()))
n = d[0]
k = d[1]
t = k - 1
while t != 0 and n % t != 0:
	t -= 1
x = n // t * k + t
print(x)


(n, k) = map(int, input().split())
import math
import sys
min1 = 1000000000
m = 0
for i in range(1, int(math.sqrt(n)) + 1):
	(p1, p2) = (999999999999, 999999999999)
	if n % i == 0:
		a = i
		b = int(n / a)
		if b < k:
			p1 = a * k + b
		if a < k:
			p2 = b * k + a
		if p1 < p2:
			m = p1
		else:
			m = p2
		if min1 > m:
			min1 = m
print(min1)


numbers = [int(i) for i in input().split()]
f = numbers[1] - 1
t = 0
while True:
	if numbers[0] % f == 0:
		break
	else:
		f -= 1
t = numbers[0] / f
print(int(t * numbers[1] + f))


(n, k) = map(int, input().split())
mod = k - 1
while n // mod != n / mod:
	mod -= 1
t = n // mod
print(t * k + mod)


(n, k) = map(int, input().split())
for i in range(k - 1, 0, -1):
	if n % i == 0:
		ost = i
		break
print(format(n * k / ost + ost, '.0f'))


a = list(map(int, input().split()))
n = a[0]
k = a[1]
l = []
for b in range(1, k):
	if n % b == 0:
		l.append(b + n / b * k)
print(int(min(l)))


(n, k) = map(int, input().split())
ans = -1
for i in range(1, k):
	if n % i == 0:
		c = n // i * k + i
		if ans == -1:
			ans = c
		else:
			ans = min(ans, c)
print(ans)


a = list(map(int, input().split()))
n = a[0]
q = []
for j in range(1, int(n) + 1):
	if n % j == 0:
		q.append((j, n // j))
s = []
for num in q:
	if num[1] < a[1]:
		g = a[1] * num[0] + num[1]
		if g % a[1] * (g // a[1]) == a[0]:
			s.append(g)
print(min(s))


(n, k) = list(map(int, input().split()))
x = -1
for b in range(k - 1, 0, -1):
	a = n / b
	if a % 1 == 0:
		a = int(a)
		if x == -1:
			x = a * k + b
		else:
			x = min(x, a * k + b)
print(x)


(n, k) = map(int, input().split())
l = []
for i in range(1, int(n ** 0.5) + 1):
	if n % i == 0:
		l.append(i)
		l.append(n // i)
l = list(set(l))
l.sort()
l.reverse()
i = 0
xm = l[i]
while i < n and l[i] >= k:
	i += 1
	xm = l[i]
xd = n // xm * k
print(xd + xm)


import math

def find_divisors(n):
	res = [k + n, k * n + 1]
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		if n / i % 1 == 0:
			n1 = int(n / i)
			n2 = i
			res += [k * n1 + n2, k * n2 + n1]
	res = list(filter(lambda j: j // k * (j % k) == n, res))
	return int(min(res))
(n, k) = list(map(lambda i: int(i), input().split()))
print(find_divisors(n))


a = b = x = xmin = 0
c = input().split()
c[0] = int(c[0])
c[1] = int(c[1])
for i in range(1, c[0] + 1):
	if c[0] % i == 0:
		a = i
		b = c[0] / i
		if c[1] > b:
			x = c[1] * a + b
		if x < xmin or xmin == 0:
			xmin = x
print(round(xmin))


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

def mod(n):
	if n < 0:
		return -n
	else:
		return n
if n < k:
	x = n + k
else:
	sqrt_n = int(n ** 1 / 2)
	x = n * k + 1
	(a, b) = (n, 1)
	for i in range(2, sqrt_n):
		if n % i == 0:
			(a, b) = (i, n // i)
			d1 = k * min(a, b) + max(a, b)
			d2 = k * max(a, b) + min(a, b)
			if d1 < x and d1 // k * (d1 % k) == n:
				x = d1
			if d2 < x and d2 // k * (d2 % k) == n:
				x = d2
print(x)


a = list(map(int, input().rstrip().split()))
n = a[0]
k = a[1]
min = 10 ** 9
for mod in range(k - 1, 0, -1):
	if n % mod == 0:
		x = n / mod * k
		if x + mod < min:
			min = x + mod
print(int(min))


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

def solution(n, k, i):
	n //= i
	return n * k + i
maxn = float('inf')
for i in range(1, k):
	if n % i == 0:
		x = solution(n, k, i)
		if x < maxn:
			maxn = x
print(maxn)


(n, k) = list(map(int, input().split()))
h = k - 1
while True:
	if n % h == 0:
		break
	h -= 1
print(n // h * k + h)


(n, k) = [int(x) for x in input().strip().split()]
ans = 1000000000
if n == 0:
	ans = k
else:
	for i in range(1, k):
		if n % i == 0:
			q = n // i
			temp = q * k + i
			ans = min(ans, temp)
print(int(ans))


(a, b) = map(int, input().split())
c = 0
for i in range(b - 1, 0, -1):
	if not a % i:
		print(b * (a // i) + i)
		break


def f(n, k):
	for i in range(min(k - 1, n), 0, -1):
		if not n % i:
			return i
(n, k) = map(int, input().split())
q = f(n, k)
print(int(n / q * k + q))


(n, k) = map(int, input().split())
deli = []
oti = 1
for i in range(k - 1, 0, -1):
	if n % i == 0:
		oti = i
		break
ans = n // oti * k + oti
print(ans)


(n, k) = map(int, input().split())
i = 0
mx = 100000000000000000000000000000000000000
for i in range(1, k):
	t = n / (i % k)
	if int(t) == t:
		t = int(t)
	else:
		continue
	mx = min(t * k + i, mx)
print(mx)


import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10, log2, floor
from itertools import permutations
from heapq import heappush, heappop, heapify
inf = float('inf')
mod = 998244353

def factorial_p(n, p):
	ans = 1
	if n <= p // 2:
		for i in range(1, n + 1):
			ans = ans * i % p
	else:
		for i in range(1, p - n):
			ans = ans * i % p
		ans = pow(ans, p - 2, p)
		if n % 2 == 0:
			ans = p - ans
	return ans

def nCr_p(n, r, p):
	ans = 1
	while n != 0 or r != 0:
		(a, b) = (n % p, r % p)
		if a < b:
			return 0
		ans = ans * factorial_p(a, p) * pow(factorial_p(b, p), p - 2, p) * pow(factorial_p(a - b, p), p - 2, p) % p
		n //= p
		r //= p
	return ans

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def is_prime(n):
	if n < 5 or n & 1 == 0 or n % 3 == 0:
		return 2 <= n <= 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			p = p * p % n
			if p == n - 1:
				break
		else:
			return False
	return True

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	large.reverse()
	small.extend(large)
	return small

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, k) = get_ints()
mini = 10 ** 9 + 7
result = all_factors(n)
length = len(result)
for i in range(length):
	x1 = result[i]
	x2 = result[length - i - 1]
	prob = x2 + x1 * k
	if prob // k * (prob % k) == n:
		if prob < mini:
			mini = prob
print(mini)


def dividers(a):
	divs = [[1, a]]
	for i in range(2, int(a ** 0.5) + 1):
		if a % i == 0:
			divs.append([i, a // i])
	return divs
(n, k) = list(map(int, input().split()))
divs = dividers(n)
g = [x for x in divs if x[0] < k]
g2 = [x for x in g if x[1] < k]
if len(g2) == 0:
	ans = g[-1]
	x = ans[0] + ans[1] * k
else:
	ans = g2[0]
	x = ans[1] + ans[0] * k
print(x)


from math import sqrt
(n, k) = map(int, input().split())
cnt = []
for i in range(1, int(sqrt(n)) + 1):
	if n % i == 0:
		cnt.append([i, n // i])
		cnt.append([n // i, i])
min1 = 10000000000000000
for i in range(len(cnt)):
	if cnt[i][1] >= k:
		continue
	x = cnt[i][0] * k + cnt[i][1]
	if x < min1:
		min1 = x
print(min1)


(n, k) = map(int, input().split(' '))
m = 10000000000000
for i in range(1, n + 1):
	if not n % i:
		j = n // i
		(t1, t2) = (10000000000000, 10000000000000)
		if j < k:
			t1 = i * k + j
		if i < k:
			t2 = j * k + i
		m = min(m, t1, t2)
print(m)


from math import *
(n, k) = map(int, input().split())
minx = k * n + 100000
for i in range(1, n + 1):
	div = int(n / i)
	if div == n / i:
		x = k * div + i
		if n == floor(x / k) * (x % k) and floor(x / k) == div and (x % k == i):
			minx = min(minx, x)
print(minx)


(n, k) = list(map(int, input().split()))
ans = 10 ** 18
for i in range(1, k):
	if n % i > 0:
		continue
	mod = i
	div = n // mod
	x = div * k + mod
	if x < ans:
		ans = x
print(ans)


def main():
	(n, k) = map(int, input().split())
	x = 1
	for i in range(k - 1, -1, -1):
		if n % i == 0:
			m = i
			break
	d = n // m
	x = d * k + m
	print(x)
main()


s = input().split(' ')
n = int(s[0])
k = int(s[1])
for a in range(1, 10000000000):
	b = n / a
	x = k * a + b
	if x % 1 == 0 and x // k * (x % k) == n:
		print(int(k * a + b))
		break


import sys, time, os
from pprint import pprint as pp
if os.environ.get('_ONPC_', False):
	stdin = open('input.txt', 'r')
	stdout = open('output.txt', 'w')
	sys.stdin = stdin
	sys.stdout = stdout
	now = time.time()
	__flag = True
else:
	__flag = False

def what(obj):
	if __flag:
		pp(obj, sys.stderr)
(n, k) = map(int, input().split())
min_x = n * k + 1
for i in range(1, k):
	if n % i == 0:
		min_x = min(min_x, n // i * k + i)
print(min_x)
if __flag:
	stdout.close()
	stdin.close()
	print(time.time() - now, file=sys.stderr)


num = input().split(' ')
(n, k) = (int(num[0]), int(num[1]))
ans = 100000000000000000
for i in range(1, k, 1):
	if n % i == 0:
		ans1 = k * (n // i) + i
		if ans1 < ans:
			ans = ans1
print(ans)


(n, k) = map(int, input().split())
v = []
for i in range(1, int(n ** 0.5) + 1):
	if n % i == 0:
		p = k * i + n // i
		q = k * (n // i) + i
		if q % k == i:
			v.append(q)
		if p % k == n // i:
			v.append(p)
print(min(v))


(n, k) = input().split(' ')
k1 = int(k)
n1 = int(n)
arr = []
for b in range(1, k1):
	x = (n1 * k1 + b * b) / b
	if (n1 * k1 + b * b) % b == 0 and n1 % b == 0:
		arr.append(x)
arr.sort()
print(int(arr[0]))


(n, k) = list(map(int, input().split()))
dels = [1] * (n + 1)
for i in range(2, n):
	if dels[i] == 1:
		if not n % i == 0:
			for j in range(i, n, i):
				dels[j] = 0
divs = [1, n]
for i in range(2, n):
	if dels[i] == 1 and (not dels[i] == n):
		divs.append(i)
xs = []
for div in divs:
	if n / div < k:
		xs.append(div * k + n / div)
print(int(min(xs)))


import itertools
(n, k) = map(int, input().split())
for i in itertools.count(1):
	if n % i == 0 and n // i < k:
		res = i * k + n // i
		print(res)
		break


def f(l):
	(n, k) = l
	r = k - 1
	while n % r > 0:
		r -= 1
	d = n // r
	return d * k + r
l = list(map(int, input().split()))
print(f(l))


(a, b) = list(map(int, input().split()))
ans = 100000000000
if a == 0:
	print(0)
else:
	for i in range(1, b):
		if a % i == 0:
			ans = min(a // i * b + i, ans)
print(ans)


(n, k) = [int(i) for i in input().split()]
max_mod = min(n, k - 1)
minimum = 99999999999999999
for i in range(1, max_mod + 1):
	if n % i == 0:
		div = n // i
		x = div * k + i
		if x < minimum:
			minimum = x
print(minimum)


(n, k) = list(map(int, input().split()))
import math
d = k - 1
while n % d != 0:
	d -= 1
print(n // d * k + d)


s = str(input())
n = int(s.split()[0])
k = int(s.split()[1])
x = 1
p = []
while x <= n:
	t = n % x
	if t == 0:
		d = int(n // x)
		m = int(n // d)
		num = int(k * d + m)
		if num // k * (num % k) == n:
			p.append(int(k * d + m))
	x += 1
m = 0
for i in p:
	if m == 0:
		m = i
	else:
		m = min(i, m)
print(m)


(n, k) = map(int, input().split())
xes = []
for ost in range(1, k):
	if n // ost == n / ost:
		xes.append(k * n / ost + ost)
xes.sort()
for el in xes:
	if el == int(el):
		print(int(el))
		break


from math import sqrt
(n, k) = map(int, input().split())
minimum = 10 ** 16 + 1
for i in range(1, int(sqrt(n)) + 1):
	if n % i == 0:
		if n // i < k:
			x = i * k + n // i
			minimum = min(minimum, x)
		if i < k:
			x = n // i * k + i
			minimum = min(minimum, x)
print(minimum)


(m, k) = map(int, input().split())
ost = k - 1
while m % ost != 0:
	ost -= 1
i = m // ost * k + ost
print(i)


(n, k) = map(int, input().split())
j = 1
m = 1
while j < k and j <= n:
	if n % j == 0:
		m = j
	j += 1
print(k * (n // m) + m)


def kek():

	def f(x):
		l = [1]
		i = 2
		while i * i <= x:
			if x % i == 0:
				l.append(i)
			i += 1
		return l
	(n, k) = map(int, input().split())
	t = f(n)
	x = 99999999999
	for i in range(len(t)):
		a = t[i]
		b = n // a
		if b < k:
			x = min(x, a * k + b)
		if a < k:
			x = min(x, b * k + a)
	print(x)
kek()


(n, k) = map(int, input().split())
f = []
a = 10 ** 10
i = 1
while i * i <= n:
	if i * i == n:
		f.append(i)
	elif n % i == 0:
		f.append(i)
		f.append(n // i)
	i += 1
f.sort()
for fi in f:
	if fi > k - 1:
		break
	a = min(a, k * (n // fi) + fi)
print(a)


(n, k) = map(int, input().split())
i = k - 1
while n % i != 0:
	i -= 1
print(int(n / i) * k + i)


(n, k) = map(int, input().split())
mn = 1000000000
for i in range(min(k - 1, n), 0, -1):
	if n % i == 0:
		temp = n // i
		tt = temp * k
		tt += i
		if tt < mn:
			mn = tt
print(mn)


from math import sqrt
(n, k) = map(int, input().split())
ms = 2 * 1000000000.0
for i in range(1, int(sqrt(n)) + 2):
	if n % i == 0:
		t = n // i
		for j in range(k * i, k * (i + 1)):
			if j % k == t:
				ms = min(j, ms)
				break
		for j in range(k * t, k * (t + 1)):
			if j % k == i:
				ms = min(j, ms)
				break
print(int(ms))


(a, k) = map(int, input().split())
l = []
for i in range(1, round(a ** 0.5) + 1):
	if a % i == 0:
		if a // i < k:
			l.append([i, a // i])
		if i < k:
			l.append([a // i, i])
b = []
for i in l:
	b.append(i[0] * k + i[1])
print(min(b))


s = input().split()
(n, k) = s
(n, k) = (int(n), int(k))
from copy import deepcopy as c

def factor(x):
	templst = []
	for i in range(1, int(x ** 0.5) + 1):
		if x % i == 0:
			templst.append(i)
	lol = c(templst)
	for y in lol[::-1]:
		if y ** 2 == x:
			pass
		else:
			templst.append(x // y)
	return templst
curlst = factor(n)
c = []
for i in range(1, k):
	if n // i in curlst:
		temp = n // i * k + i
		if temp // k * (temp % k) == n:
			c.append(temp)
print(min(c))


(n, k) = map(int, input().split())
print(min([int(n * k / i + i) for i in list(range(1, k)) if int(n * k / i + i) // k * (int(n * k / i + i) % k) == n]))


(n, k) = (int(x) for x in input().split())
ans = n * k + 1
for t in range(2, k):
	if n % t == 0:
		ans = min(ans, n // t * k + t)
print(ans)


from math import sqrt
(n, k) = map(int, input().split())
x_max = []
res = []
for i in range(1, int(sqrt(n) + 1)):
	if not n % i:
		res.append([i, n // i])
for i in res:
	x = k * i[0] + i[1]
	if x % k == i[0] and x // k == i[1]:
		x_max.append(x)
	if x % k == i[1] and x // k == i[0]:
		x_max.append(x)
	x = k * i[1] + i[0]
	if x % k == i[0] and x // k == i[1]:
		x_max.append(x)
	if x % k == i[1] and x // k == i[0]:
		x_max.append(x)
print(min(x_max))


(n, k) = map(int, input().split())
a = [1, n]
for i in range(2, int(n ** 0.5 + 1)):
	if n % i == 0:
		a.append(i)
		a.append(int(n / i))
a.sort()
for i in range(len(a) - 1, -1, -1):
	if a[i] < k:
		j = a[i]
		break
print(int(j + k * n / j))


(n, k) = map(int, input().split())
r = 1000000000000000000
for i in range(1, k):
	if n % i == 0:
		a = n // i
		r = min(r, k * a + i)
print(r)


a = [int(i) for i in input().split()]
(n, k) = (a[0], a[1])
divider = -1
for i in range(n // k, n):
	if n % (i + 1) == 0:
		divider = n // (i + 1)
		break
print(k * n // divider + divider)


(n, k) = map(int, input().split())
x = 10 ** 9
for i in range(1, k):
	if n % i == 0:
		m = n // i
	x = min(x, m * k + i)
print(x)


import math
(n, k) = map(int, input().split())
diffs = []
for i in range(1, math.ceil(math.sqrt(n)) + 1):
	if n % i == 0:
		a = i * k + n // i
		b = k * (n // i) + i
		if a // k * (a % k) == n:
			diffs.append(a)
		if b // k * (b % k) == n:
			diffs.append(b)
ans = min(diffs)
print(ans)


(n, k) = map(int, input().split())
if n == 0:
	print(0)
	return
m = 100000000000000000
for i in range(1, k):
	if n % i == 0:
		m = min(m, n // i * k + i)
print(m)


(n, k) = map(int, input().split())
x = float('inf')
for c in range(1, k):
	x1 = (n * k + c ** 2) / c
	if int(x1) == x1 and x1 < x:
		c1 = x1 % k
		a = (x1 - c1) // k
		if a * c1 == n:
			x = x1
print(int(x))


n = input().split()
(n, k) = (int(n[0]), int(n[1]))
x = 0
for i in range(1, 10 ** 8):
	if n % i == 0:
		if n // i < k:
			x = i * k + n // i
			break
print(x)


inp = list(map(int, input().split()))
n = inp[0]
k = inp[1]
i = k - 1
while i >= 1:
	if n % i == 0:
		a = n // i
		print(a * k + i)
		break
	else:
		i -= 1


(a, b) = map(int, input().split())
r = 0
for i in range(1, b):
	if a % i == 0 and i > r:
		r = i
q = a // r
print(q * b + r)


a = input()
zz = 0
q = int(a.split()[0])
w = int(a.split()[1])
for i in range(w - 1, 0, -1):
	if q % i == 0:
		t = i
		y = q // i
		break
print(w * y + t)


from math import sqrt

def factor(n):
	natural_del = []
	for a in range(1, int(n ** 0.5) + 1):
		if n % a == 0:
			natural_del.append(a)
			natural_del.append(n // a)
	return natural_del
(n, k) = map(int, input().split())
if n != 1:
	z = factor(n)
	z.append(n)
	fjnt = 1 + k * n
	for d in z:
		if d < k:
			fjnt = min(d + k * (n // d), fjnt)
	print(fjnt)
else:
	print(k + 1)


(n, k) = map(int, input().split())
z = k - 1
while z > 0:
	if n % z == 0:
		break
	z = z - 1
m = int(n / z)
ans = m * k + z
print(ans)


from math import sqrt
(n, k) = input().split()
n = int(n)
k = int(k)
ans = None
for i in range(1, k):
	if n % i == 0:
		if ans == None:
			ans = k * (n // i) + i
		elif k * (n // i) + i < ans:
			ans = k * (n // i) + i
print(ans)


(n, k) = map(int, input().split())
mn = int(1e+20)
for i in range(1, k):
	if not n % i:
		mn = min(mn, k * (n // i) + i)
print(mn)


(n, k) = map(int, input().split())
fr = min(k - 1, n)
for i in range(fr, -1, -1):
	if n % i == 0:
		div = i
		break
print(n // div * k + div)


import math
import sys

def main():
	(n, k) = [int(x) for x in input().split(' ')]
	ans = int(1000000000000.0)
	for b in range(1, k):
		for x in range(n // b * k, n // b * k + k):
			if x % k * (x // k) == n:
				ans = min(ans, x)
	print(ans)
main()


(n1, k) = map(int, input().split(' '))
ans = 4557430888798830399
for i in range(1, k):
	if n1 % i == 0:
		y = n1 / i
		ans = min(y * k + i, ans)
print('%d' % ans)


from sys import stdin, stdout
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd, sqrt, factorial, log2, floor
import heapq

def prime(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return 0
		i += 1
	return 1
(n, k) = mp()
if n == k:
	print(n * k + 1)
elif n < k:
	print(k + n)
elif prime(n):
	print(n * k + 1)
else:
	ist = 0
	for i in range(k - 1, 0, -1):
		if n % i == 0:
			ist = i
			break
	second = n // ist
	print(k * second + ist)


(n, k) = map(int, input().split())
x = 0
ar = []
for i in range(k - 1, 0, -1):
	if n % i == 0:
		x = n // i * k + i
		ar.append(x)
print(min(ar))


def divmod():
	inp = input().split()
	n = int(inp[0])
	k = int(inp[1])
	d = 1
	while d <= n:
		if n % d == 0:
			x = d * k
			for i in range(1, k):
				if d * i == n:
					return x + i
			d += 1
		else:
			d += 1
print(divmod())


(n, k) = map(int, input().split())
x = float('inf')
for m in range(1, k):
	if n % m == 0:
		x = min(x, n // m * k + m)
print(x)


(n, k) = list(map(int, input().split()))
ans = 10 ** 9
for b in range(1, k):
	if k * n % b == 0:
		x = k * n // b + b
		if x % k * (x // k) == n:
			ans = min(ans, k * n // b + b)
print(ans)


digl = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
mod = 10 ** 9 + 7
(n, k) = f()
(a, b) = (0, 0)
for i in range(k - 1, 0, -1):
	if n % i == 0:
		b = i
		break
print(k * (n // b) + b)


(n, k) = list(map(int, input().split()))
result = 10 ** 26
for i in range(1, k):
	if n % i == 0:
		t = n // i
		result = min(result, t * k + i)
print(result)


from math import *
(n, k) = map(int, input().split())
(x, y) = (0, 0)
for i in range(1, ceil(sqrt(n)) + 1):
	if n % i == 0:
		a = i
		b = n // i
		if max(a, b) > k - 1:
			if min(a, b) > k - 1:
				break
			elif min(a, b) > y:
				y = min(a, b)
				x = max(a, b)
		elif max(a, b) > y:
			y = max(a, b)
			x = min(a, b)
ans = x * k + y
print(ans)


INPUT = [int(i) for i in input().split()]
(n, k) = (INPUT[0], INPUT[1])
if n <= k - 1:
	print(k + n)
elif n == k and n % 2 == 0:
	print(2 * k + n // 2)
else:
	div = k - 1
	while n % div != 0:
		div -= 1
	print(n * k // div + div)


a = list(map(int, input().split()))
fir = a[0]
sec = a[1]
if sec > fir:
	res = fir + sec
else:
	i = sec - 1
	while i > 0:
		if fir % i == 0:
			num = i
			break
		i = i - 1
	res = num + fir // num * sec
if fir == 0:
	res = 0
print(res)


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

def solve(n, k):
	d = 1
	while d <= n:
		if n % d == 0:
			if n // d < k:
				return k * d + n // d
		d += 1
print(solve(n, k))


(n, k) = [int(i) for i in input().split()]
ost = k - 1
while n % ost != 0:
	ost -= 1
x = n // ost * k + ost
print(x)


(n, k) = map(int, input().split())
second = int(0)
first = int(0)
for i in range(1, k):
	if n % i == 0:
		second = i
first = int(n / second)
print(first * k + second)


(n, k) = map(int, input().split())
minn = 10 ** 9
for m in range(1, k):
	if n % m == 0:
		if minn > n // m * k + m:
			minn = n // m * k + m
print(minn)


(n, k) = map(int, input().split())
Min = 10 ** 99
for i in range(1, k):
	if n // i == n / i:
		Min = min(n // i * k + i, Min)
print(Min)


def main():
	arr = input().split()
	n = int(arr[0])
	k = int(arr[1])
	for x in range(k - 1, 0, -1):
		if n % x == 0:
			print(x + n // x * k)
			break
main()


from math import sqrt
(n, k) = [int(x) for x in input().split()]
if n < k:
	print(n + k)
else:
	lst = []
	temp = 0
	for x in range(1, int(sqrt(n)) + 1):
		if n % x == 0:
			lst.append((x, n // x))
			temp += 1
	tempmin = lst[0][1] * k + lst[0][0]
	for i in range(temp):
		if tempmin > lst[i][1] * k + lst[i][0] and k > lst[i][0]:
			tempmin = lst[i][1] * k + lst[i][0]
		if tempmin > lst[temp - i - 1][0] * k + lst[temp - i - 1][1] and k > lst[temp - i - 1][1]:
			tempmin = lst[temp - i - 1][0] * k + lst[temp - i - 1][1]
	print(tempmin)


(n, k) = map(int, input().split())
from math import sqrt
from math import ceil
x2 = float('inf')
t = max(ceil(sqrt(n)), int(sqrt(n)) + 1)
for i in range(int(sqrt(n)), 0, -1):
	(r1, r2) = (float('inf'), float('inf'))
	if i < k and n % i == 0:
		r1 = k * (n // i) + i
	if k > n // i and n % (n // i) == 0:
		r2 = k * i + n // i
	x2 = min(x2, r1, r2)
print(x2)


(n, k) = (int(x) for x in input().split())
for i in range(k - 1, 0, -1):
	if n % i == 0:
		print(n // i * k + i)
		return


from math import inf
(n, k) = list(map(int, input().split()))
ans = inf
for i in range(1, k):
	if n % i == 0:
		ans = min(ans, n // i * k + i)
print(ans)


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

def nearest_div(n, k):
	for i in range(k - 1, -1, -1):
		if not n % i:
			return i
i = nearest_div(n, k)
print(k * (n // i) + i)


(n, k) = map(int, input().split())
if n >= k:
	for i in range(n // 2, 0, -1):
		if n % i == 0:
			if i < k:
				x = i
				break
	z = n // x
	ans = z * k + x
	print(ans)
else:
	print(n + k)


from sys import exit
(n, k) = map(int, input().split())
for i in range(1, n // 2 + 1):
	if n % i == 0:
		j = n // i
		if j < k:
			print(i * k + j)
			exit(0)
print(n * k + 1)


(n, k) = map(int, input().split())
minn = 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
for i in range(1, k):
	if n % i == 0:
		minn = n // i * k + i
print(minn)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
import threading
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')
(n, k) = map(int, input().split())
x = 10 ** 9
for mod in range(1, k):
	if n % mod == 0:
		div = n // mod
		num = div * k + mod
		x = min(x, num)
print(x)


(n, k) = map(int, input().split())
for number in range(1, n + 1):
	if not n % number:
		temp = number * k + n // number
		if temp // k * (temp % k) == n:
			print(temp)
			break


def f(a, b):
	for i in range(min(b - 1, a), 0, -1):
		if not a % i:
			return i

def f1(a, b, c):
	return a * b // c
(n, k) = map(int, input().split())
c = f(n, k)
print(f1(n, k, c) + c)


(n, k) = map(int, input().split())
j = 1
if k > n:
	x = k + n
else:
	for i in range(1, k + 1):
		if n % (k - i) == 0:
			while (k - i) * j < n:
				j += 1
			x = k * j + k - i
			break
print(x)


(n, k) = list(map(int, input().split()))
for i in range(k - 1, 0, -1):
	r = n / i
	if r != int(r):
		continue
	x = r * k
	if r * i == n:
		print(int(x + i))
		exit()


y = input().split()
k = int(y[0])
n = int(y[1])
deliteli = []
for i in range(1, k + 1):
	if k % i == 0:
		deliteli.append([i, k // i])
answers = []
for i in deliteli:
	if i[1] >= n:
		continue
	answers.append(i[0] * n + i[1])
print(min(answers))


import math
(n, k) = map(int, input().split())
d = 1
maxi = -1
while d < math.sqrt(n) + 1:
	if n % d == 0:
		if d < k:
			maxi = max(maxi, d)
		if n // d < k:
			maxi = max(maxi, n // d)
	d += 1
print(n // maxi * k + maxi)


li = list(map(int, input().split()))
n = li[0]
k = li[1]
ans = []
for r in range(1, k):
	m = n * k / r + r
	if str(m)[len(str(m)) - 1] == '0':
		p = int(m - r) / k
		if str(p)[len(str(p)) - 1] == '0':
			ans.append(m)
print(int(min(ans)))


(n, k) = map(int, input().split())
(dl, ans) = ([], [])
for i in range(1, n + 1):
	if n % i == 0:
		dl.append(i)
for i in range(len(dl)):
	sk1 = dl[i]
	sk2 = n // sk1
	for j in range(sk1 * k, sk1 * k + k):
		if j // k == sk1:
			if j % k == sk2:
				ans.append(j)
print(min(ans))


(n, k) = map(int, input().split())
i = 1
ans = []
for p in range(1, k):
	a = str(n * k / p + p)
	b = a.index('.')
	if len(a) - (b + 1) == 1 and a[-1] == '0':
		ans.append(int(float(a)))
answer = []
for i in ans:
	if i // k * (i % k) == n:
		answer.append(i)
print(min(answer))


(n, k) = map(int, input().split())
mns = 99999999999999999
i = 1
while i in range(1, k):
	mns1 = n // i * k + i
	mns2 = mns1 // k * (mns1 % k)
	if mns2 == n:
		mns = min(mns, mns1)
	i += 1
print(mns)


(n, k) = map(int, input().split())
ans = 2 * 10 ** 9
i = 1
while i * i <= n:
	if n % i == 0:
		if i < k:
			ans = min(ans, i + n // i * k)
		if n // i < k:
			ans = min(ans, n // i + i * k)
	i += 1
print(ans)


from math import sqrt
(n, k) = map(int, input().split())
x = float('inf')
max_div = int(sqrt(n))
for div in range(1, max_div + 1):
	if n % div == 0:
		div2 = n // div
		if div2 < k:
			x = min(x, div * k + div2)
		if div < k:
			x = min(x, div2 * k + div)
print(x)


import sys
import math
import bisect

def main():
	(n, k) = map(int, input().split())
	A = []
	for i in range(1, k):
		if n % i == 0:
			m = n // i
			val = k * m + i
			A.append(val)
	print(min(A))
main()


(n, k) = map(int, input().strip().split(' '))
f = 0
if k > n:
	i = n
else:
	i = k - 1
while i >= 1:
	if n % i == 0:
		x = i + n // i * k
		f = 1
		print(x)
		break
	else:
		i -= 1
if f == 0:
	print(0)


b = input().split()
b = [int(i) for i in b]
(n, k) = b
delit = []
ans = []
for i in range(1, n + 1):
	if n % i == 0:
		delit.append(i)
for i in delit:
	a = k * i + n // i
	if a % k == n // i:
		ans.append(a)
print(min(ans))


(n, k) = map(int, input().split())
m = 999999
for i in range(1, k):
	if not n % i:
		x = n * k / i + i
		if x < m:
			m = x
print(int(x))


def case(x, y, result):
	res = x * k + y
	if res // k == x and res % k == y:
		result = min(result, res)
	return result
(n, k) = map(int, input().split())
result = 100000000000000000000
for i in range(1, int(n ** 0.5) + 1):
	if n % i == 0:
		(x, y) = (i, n // i)
		result = case(x, y, result)
		(x, y) = (n // i, i)
		result = case(x, y, result)
print(result)


(n, k) = map(int, input().split())
t = k - 1
while n % t != 0:
	t -= 1
f = n // t
x = f * k + t
print(x)


(n, k) = map(int, input().split())
j = k - 1
while j > 1:
	if n % j == 0:
		break
	j -= 1
x = n // j * k + j
print(x)


import math
(n, k) = map(int, input().split())
num = []
for i in range(1, math.ceil(math.sqrt(n)) + 1):
	if n % i == 0:
		num.append([i, n // i])
		num.append([n // i, i])
num.sort()
p = True
i = 0
while p:
	a = num[i][0]
	b = num[i][1]
	x = k * a + b
	if x // k == a:
		p = False
	i += 1
print(x)


s = input().split()
(n, k) = (int(s[0]), int(s[1]))
for l in range(k - 1, 0, -1):
	if n % l == 0:
		print(n // l * k + l)
		break


(n, k) = input().split()
(n, k) = (int(n), int(k))
i = 1
ost = 1
while 1 > 0:
	ost = 1
	while ost < k:
		if n % ost == 0:
			i = n // ost
		ost += 1
	ost = n / i
	break
print(int(i * k + ost))


(n, k) = map(int, input().split())
m = min(n, k) + 1
l = []
for i in range(1, m):
	if n % i == 0:
		x = i + k * (n // i)
		if x // k * (x % k) == n:
			l.append(x)
l.sort()
print(l[0])


(n, k) = map(int, input().split())
(a, b) = (0, 0)
lx = n * k + 1
x = 0
for i in range(1, k):
	if n % i == 0:
		b = n // i
		x = b * k
		x += i
		x = min(x, lx)
print(x)


(n, k) = list(map(int, input().split()))
x = 1
res = []
for i in range(1, k):
	if n % i != 0:
		continue
	div = n // i
	res.append(div * k + i)
print(min(res))


def vv(a, b):
	while 1:
		if a % b == 0:
			return b
		b -= 1
(n, k) = map(int, input().split())
a = int(vv(n, k - 1))
print(n // a * k + a)


from sys import exit
(n, k) = (int(x) for x in input().split())
for i in range(k - 1, 0, -1):
	if n % i == 0:
		print(n // i * k + i)
		exit(0)


(n, k) = map(int, input().split())
a = []
for i in range(1, min(int(n ** 0.5) + 1, k)):
	if n % i == 0:
		a.append((i, n // i))
ans = int(10000000000.0)
for i in range(len(a)):
	if a[i][0] * k + a[i][1] < ans and a[i][1] < k:
		ans = a[i][0] * k + a[i][1]
	if a[i][1] * k + a[i][0] < ans and a[i][0] < k:
		ans = a[i][1] * k + a[i][0]
print(ans)


(n, k) = map(int, input().split())
x = 1
m = 100000000000000000000000000
a = [0] * k
for i in range(0, k):
	if i == 0 or n % i != 0:
		a[i] = m
	else:
		a[i] = n // i * k + i
print(min(a))


(n, k) = list(map(int, input().split()))
mind = 1
for i in range(1, n + 1):
	if n % i == 0 and n // i < k:
		mind = i
		break
x = k * mind
while x % k != n // mind:
	x += 1
print(x)


(n, k) = [int(x) for x in input().split()]
if n == 0:
	print(0)
else:
	p = k - 1
	while n % p != 0:
		p -= 1
	m = n / p
	print(int(m * k + p))


def process(n, k):
	answer = float('inf')
	for i in range(1, k):
		if n % i == 0:
			x = n // i * k + i
			answer = min(answer, x)
	return answer
(n, k) = [int(x) for x in input().split()]
print(process(n, k))


import math
import os
import random
import re
import sys

def probl(n, k):
	if n < k:
		return n + k
	else:
		for i in range(1, n + 1):
			if n % i == 0:
				if n / i % k == n / i:
					return int(i * k + n / i)
nk = list(map(int, input().rstrip().split()))
n = nk[0]
k = nk[1]
print(probl(n, k))


(n, k) = map(int, input().split())
min_x = n * k + 1
for i in range(1, k):
	if n % i == 0:
		min_x = min(min_x, n // i * k + i)
print(min_x)


def to_div(n, k):
	pair = []
	i = 1
	while i <= n:
		tmp = []
		if n % i == 0 and n // i < k:
			tmp.append(i)
			tmp.append(n // i)
			pair.append(tmp)
		i += 1
	return pair
n = input().split()
k = int(n[1])
n = int(n[0])
pairs = to_div(n, k)
x = []
for i in pairs:
	m = i[0]
	q = i[1]
	tmp = m * k
	tmp += q
	x.append(tmp)
mini = x[0]
for i in x:
	if i < mini:
		mini = i
print(mini)


def calcu(k, n):
	l = []
	for N in range(1, k):
		if n % N == 0:
			x = int(n * k / N) + N
			if x // k * (x % k) == n:
				l.append(x)
	return min(l)
(n, k) = map(int, input().split(' '))
print(calcu(k, n))


(n, k) = map(int, input().split())
c = k - 1
while n % c != 0:
	c -= 1
print(c + n // c * k)


(n, k) = input().split()
(n, k) = (int(n), int(k))
q = int(n / k) + 1
while n % q != 0:
	q += 1
print(k * q + int(n / q))


import math
d = []
(n, k) = input().split()
n = int(n)
k = int(k)
c = int(n ** 0.5)
while c > 0:
	if n % c == 0 and int(n / c * k + c) // k * (int(n / c * k + c) % k) == n:
		d.append(int(n / c * k + c))
	v = int(c * k + n / c)
	if n % c == 0 and v // k * (v % k) == n:
		d.append(int(c * k + n / c))
	c -= 1
d.sort()
print(d[0])


(n, k) = map(int, input().split())
best = n * k + 1
for ost in range(1, k):
	if n % ost == 0:
		best = min(best, n // ost * k + ost)
print(best)


import math
a = input().split()
(n, k) = (int(a[0]), int(a[1]))
res = []
if n == 1:
	print(k + 1)
else:
	for i in range(1, math.ceil(math.sqrt(int(n))) + 1):
		if n % i == 0:
			if (i + k * n / i) // k * ((i + k * n / i) % k) == n:
				res.append(i + k * n / i)
			if (i * k + n / i) // k * ((i * k + n / i) % k) == n:
				res.append(i * k + n / i)
	print(int(min(res)))


(n, k) = map(int, input().split())
r = float('inf')
for i in range(1, k):
	if n % i == 0:
		r = min(r, n / i * k + i)
print(int(r))


s = list(map(int, input().split()))
n = s[0]
k = s[1]
nums = []
for i in range(1, k):
	if n % i == 0:
		nums.append(n // i * k + i % k)
print(min(nums))


(n, k) = map(int, input().split())
ans = 1000000000
i = k - 1
while n % i != 0:
	i -= 1
ans = i + k * (n // i)
print(ans)


def main():
	(n, k) = map(int, input().split())
	x = float('+inf')
	for r in range(1, k):
		if n % r != 0:
			continue
		q = n // r
		x = min(x, q * k + r)
	print(x)
main()


(n, k) = list(map(int, input().split()))
for a in range(1, 10 ** 8):
	if n % a == 0 and n / a < k:
		print(int(a * k + n / a))
		break


(n, k) = map(int, input().split())
pizda = k - 1
while n % pizda != 0:
	pizda -= 1
print(n // pizda * k + pizda)


(n, k) = map(int, input().split())
flag = True
mx = n * k
for b in range(1, k):
	if n % b == 0:
		a = n // b
		x = a * k + b
		if x < mx:
			mx = x
print(x)


from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
(n, k) = list(map(int, input().split()))
fac = sorted(list(factors(n)))
for i in range(len(fac)):
	l = fac[i]
	r = n // fac[i]
	if (l * k + r) // k * ((l * k + r) % k) == n:
		print(l * k + r)
		break


s = input()
(h, y) = s.split(' ')
h = int(h)
y = int(y)
g = y - 1
while g > 1:
	if h % g == 0:
		break
	g = g - 1
a = h // g * y + g
print(a)


from math import sqrt
(n, k) = map(int, input().split())
values = []
for i in range(1, int(sqrt(n) + 1)):
	if n % i == 0:
		values.append([i, n // i])
		values.append([n // i, i])
minim = 1000000000000
for dividers in values:
	if dividers[1] >= k:
		continue
	value = dividers[0] * k + dividers[1]
	if value < minim:
		minim = value
print(minim)


(n, k) = map(int, input().split())
i = 0
chis = [i + 1 for i in range(k - 1)]
minimum = n // chis[i] * k + chis[i]
for i in range(1, len(chis)):
	if n % chis[i] == 0:
		if minimum > n // chis[i] * k + chis[i]:
			minimum = n // chis[i] * k + chis[i]
print(minimum)


import math
(n, k) = list(map(int, input().split()))
if k == n:
	print(k * k + 1)
elif n < k:
	print(n + k)
elif n > k:
	x = k - 1
	while n % x != 0:
		x -= 1
	a = n // x
	b = a * k
	c = b + x
	print(c)