10^{10^{10}} participants, including Takahashi, competed in two programming contests.
In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.
The score of a participant is the product of his/her ranks in the two contests.
Process the following Q queries:
 - In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.

-----Constraints-----
 - 1 \leq Q \leq 100
 - 1\leq A_i,B_i\leq 10^9(1\leq i\leq Q)
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
Q
A_1 B_1
:
A_Q B_Q

-----Output-----
For each query, print the maximum possible number of participants whose scores are smaller than Takahashi's.

-----Sample Input-----
8
1 4
10 5
3 3
4 11
8 9
22 40
8 36
314159265 358979323

-----Sample Output-----
1
12
4
11
14
57
31
671644785

Let us denote a participant who was ranked x-th in the first contest and y-th in the second contest as (x,y).
In the first query, (2,1) is a possible candidate of a participant whose score is smaller than Takahashi's. There are never two or more participants whose scores are smaller than Takahashi's, so we should print 1.

Source: atcoder | Difficulty: HARD


Solutions:
def i1():
	return int(input())

def i2():
	return [int(i) for i in input().split()]
q = i1()
import math
y = []
for i in range(q):
	y.append(i2())
for (a, b) in y:
	x = a * b
	c = int(math.sqrt(x))
	if c ** 2 == x:
		c -= 1
	z = 2 * c
	if c > 0 and x // c == c:
		z -= 1
	if c > 0 and x % c == 0 and (x // c - 1 == c):
		z -= 1
	if a <= c:
		z -= 1
	if b <= c:
		z -= 1
	print(z)


from math import sqrt
Q = int(input())
que = []
for i in range(Q):
	que.append(tuple(map(int, input().split())))
for q in que:
	if q[0] == q[1]:
		print(2 * q[0] - 2)
	else:
		a = q[0] * q[1]
		p = int(sqrt(a))
		if p * p == a:
			p -= 1
		if a > p * (p + 1):
			print(2 * p - 1)
		else:
			print(2 * p - 2)


from math import sqrt
Q = int(input())
for i in range(Q):
	(A, B) = list(map(int, input().split(' ')))
	if A == B or A + 1 == B:
		print(2 * A - 2)
		continue
	mul = A * B
	C = int(sqrt(mul))
	if C * C == mul:
		C -= 1
	if (C + 1) * C < mul:
		print(2 * C - 1)
	else:
		print(2 * C - 2)


def inpl():
	return [int(i) for i in input().split()]
Q = int(input())
for _ in range(Q):
	(A, B) = sorted(inpl())
	c = int(-(-(A * B) ** 0.5 // 1) - 1)
	ans = A - 1 + max(0, c - A) + (-(-A * B // (c + 1)) - 1)
	print(ans)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 15
mod = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	rr = []
	for _ in range(n):
		(a, b) = LI()
		t = a * b
		s = int(t ** 0.5)
		if t < 3:
			rr.append(0)
		elif a == b:
			if (a - 1) * (b + 1) < t:
				rr.append((a - 1) * 2)
			else:
				rr.append((a - 1) * 2 - 1)
		elif s * s == t:
			rr.append((s - 1) * 2 - 1)
		elif s * (s + 1) < t:
			rr.append(s * 2 - 1)
		else:
			rr.append((s - 1) * 2)
	return '\n'.join(map(str, rr))
print(main())


import math

def __starting_point():
	q = int(input())
	for i in range(q):
		(a, b) = list(map(int, input().split()))
		prod = a * b
		rootInt = int(math.sqrt(prod))
		if a == b:
			print((a - 1) * 2)
		elif math.sqrt(prod) == rootInt:
			print((rootInt - 2) * 2 + 1)
		elif rootInt * (rootInt + 1) < prod:
			print((rootInt - 1) * 2 + 1)
		else:
			print((rootInt - 1) * 2)
__starting_point()


q = int(input())
for i in range(q):
	(x, y) = map(int, input().split())
	if x == y:
		print(2 * (x - 1))
		continue
	z = int((x * y) ** 0.5)
	if z ** 2 == x * y:
		z -= 1
	ans = 2 * z - 2
	if z * (z + 1) < x * y:
		ans += 1
	print(ans)


Q = int(input())
(A, B) = ([None] * Q, [None] * Q)
for i in range(Q):
	(A[i], B[i]) = sorted(map(int, input().split()))

def solve(a, b):
	w = a * b - 1
	(left, right) = (0, b - a)
	while right - left > 1:
		x = (left + right) // 2
		v = w // (a + x)
		if v < a:
			right = x
		else:
			left = x
	n = left
	(left, right) = (0, n)
	while right - left > 1:
		x = (left + right) // 2
		v = w // (a + x)
		if v < a + x:
			right = x
		else:
			left = x
	return right + w // (a + right) - w // (a + n)

def main():
	for (a, b) in zip(A, B):
		ans = 2 * (a - 1) + solve(a, b)
		print(ans)

def __starting_point():
	main()
__starting_point()


from math import sqrt

def func(a, b):
	if a == b:
		return (a - 1) * 2
	else:
		sq = int(sqrt(a * b))
		if a * b == sq ** 2:
			return (sq - 1) * 2 - 1
		elif sq * (sq + 1) > a * b:
			return (sq - 1) * 2
		elif sq * (sq + 1) == a * b:
			if abs(a - b) == 1:
				return (sq - 1) * 2
			else:
				return (sq - 1) * 2
		else:
			return sq * 2 - 1
q = int(input())
for _ in range(q):
	(a, b) = map(int, input().split())
	print(func(a, b))


q = int(input())
for i in range(q):
	(a, b) = list(map(int, input().split()))
	if a == b:
		ans = 2 * a - 2
	elif abs(a - b) == 1:
		ans = 2 * min(a, b) - 2
	else:
		c = (a * b) ** 0.5
		if c % 1 == 0:
			c = int(c) - 1
		else:
			c = int(c)
		if c * (c + 1) >= a * b:
			ans = 2 * c - 2
		else:
			ans = 2 * c - 1
	print(ans)


import math
q = int(input())
for j in range(q):
	AB = [int(i) for i in input().split()]
	AB.sort()
	ab = AB[0] * AB[1]
	for i in range(int(math.sqrt(ab)), AB[1] + 1):
		if i * i >= ab:
			x = i - 1
			break
	if x == 0:
		print(0)
		continue
	for i in range(int(ab / x), ab + 1):
		if x * i >= ab:
			y = i - 1
			break
	cnt1 = 2 * x
	cnts = 1 if x == y else 0
	cntdd = 1 if x - AB[0] >= 0 else 0
	cntdu = 1 if AB[1] - y >= 0 and (AB[1] + 1) * (x - AB[1] + y) >= ab else 0
	print(cnt1 - cnts - cntdd - cntdu)


from math import *
Q = int(input())
data = []
for _ in range(Q):
	(A, B) = map(int, input().split())
	data.append((A, B))
for (A, B) in data:
	res = 0
	if A == B == 1:
		print(0)
	else:
		r = floor((A * B) ** 0.5)
		if r ** 2 == A * B:
			r -= 1
		if (A * B - 1) // r == r:
			res -= 1
		if A <= r or B <= r:
			res -= 1
		res += r * 2
		print(res)


Q = int(input())
querys = [tuple(map(int, input().split())) for _ in range(Q)]
anss = []
for (A, B) in querys:
	if A > B:
		(A, B) = (B, A)
	if A == B:
		ans = 2 * (A - 1)
	elif A + 1 == B:
		ans = 2 * (A - 1)
	else:
		C = -(-(A * B) ** 0.5 // 1) - 1
		if C * (C + 1) >= A * B:
			ans = 2 * (C - 1)
		else:
			ans = 2 * C - 1
	anss.append(int(ans))
print('\n'.join(map(str, anss)))


import math

def __starting_point():
	Q = int(input())
	for _ in range(Q):
		(a, b) = list(map(int, input().split()))
		big = max(a, b)
		small = min(a, b)
		c = math.floor(math.sqrt(a * b))
		if c * c == a * b:
			c -= 1
		if big == small:
			print(2 * big - 2)
		elif big == small + 1:
			print(2 * small - 2)
		elif c * (c + 1) >= a * b:
			print(2 * c - 2)
		else:
			print(2 * c - 1)
__starting_point()


import math
Q = int(input())
A_list = []
B_list = []
for _ in range(Q):
	(A, B) = list(map(int, input().split()))
	A_list.append(min(A, B))
	B_list.append(max(A, B))
for i in range(Q):
	A = A_list[i]
	B = B_list[i]
	R = int(math.sqrt(A * B))
	if A >= B - 1:
		print(2 * A - 2)
	elif R * R == A * B:
		print(2 * R - 3)
	elif R * (R + 1) >= A * B:
		print(2 * R - 2)
	else:
		print(2 * R - 1)


for a in [*open(0)][1:]:
	(a, b) = map(int, a.split())
	c = int((a * b) ** 0.5)
	print((a * b - (a != b)) // c + c - 2)


n = int(input())
arr = []
for i in range(n):
	arr.append([int(x) for x in input().split()])
for pair in arr:
	a = pair[0]
	b = pair[1]
	t = a * b
	s = int(t ** 0.5)
	if t < 3:
		print(0)
	elif a == b:
		if (a - 1) * (b + 1) < t:
			print((a - 1) * 2)
		else:
			print((a - 1) * 2 - 1)
	elif s * s == t:
		print((s - 1) * 2 - 1)
	elif s * (s + 1) < t:
		print(s * 2 - 1)
	else:
		print((s - 1) * 2)


import sys, math, copy
HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = 'abcdefghijklmnopqrstuvwxyz'

def main():
	q = int(input())
	for i in range(q):
		print(wc())

def wc():
	(a, b) = list(map(int, input().split()))
	if a == b:
		return 2 * (a - 1)
	if b > a:
		(a, b) = (b, a)
	sqt = (a * b) ** 0.5
	area1 = math.ceil(sqt) - 1
	area2 = math.ceil(sqt) - 1 - b
	area3 = b - 1
	adj = -1 if (math.ceil(sqt) - 1) * math.ceil(sqt) >= a * b else 0
	return area1 + area2 + area3 + adj
main()


def st2(x, y):
	l = int((x * y * 4 - 1) ** 0.5)
	return l - 1 - int(x != y)

def st3(x, y):
	(p, q) = (1, (max(x, y) + 1) * 2)
	while q - p > 1:
		m = (p + q) // 2
		if m * m < x * y * 4:
			p = m
		else:
			q = m
	l = p
	return l - 1 - int(x != y)

def query(x, y):
	print(st3(x, y))

def main():
	n = int(input())
	for _ in range(n):
		(x, y) = map(int, input().split())
		query(x, y)

def __starting_point():
	main()
__starting_point()


q = int(input())
for i in range(q):
	(a, b) = list(map(int, input().split()))
	(a, b) = (min(a, b), max(a, b))
	(l, r) = (a - 1, b + 1)
	while r - l != 1:
		t = (l + r) // 2
		if t * t < a * b:
			l = t
		else:
			r = t
	c = l
	(l, r) = (a - 1, b + 1)
	while r - l != 1:
		t = (l + r) // 2
		if t * (t + 1) < a * b:
			l = t
		else:
			r = t
	d = l
	print(a - 1 + max(d * 2 - a, c * 2 - 1 - a) + int(a == b))


from math import ceil
Q = int(input())
AB = [list(map(int, input().split())) for i in range(Q)]
for (a, b) in AB:
	(a, b) = (min(a, b), max(a, b))
	C = int((a * b) ** 0.5)
	if a == b:
		print(2 * a - 2)
		continue
	if a + 1 == b:
		print(2 * a - 2)
		continue
	if C ** 2 == a * b:
		C -= 1
	if C * (C + 1) < a * b:
		print(2 * C - 1)
	else:
		print(2 * C - 2)


n = int(input())
l = []
for i in range(n):
	(a, b) = list(map(int, input().split()))
	p = int((a * b) ** (1 / 2))
	if p * (p + 1) < a * b:
		ans = int(2 * p - 1)
	elif p ** 2 == a * b and (not a == b):
		ans = int(2 * p - 3)
	else:
		ans = int(2 * p - 2)
	l.append(ans)
for i in range(n):
	print(l[i])


def bsearch(target, min_i, max_i, func):
	if func(max_i) < target:
		return max_i
	if target <= func(min_i):
		return None
	index = (max_i + min_i) // 2
	while True:
		if max_i - min_i <= 1:
			return min_i
		if func(index) < target:
			(index, min_i) = ((index + max_i) // 2, index)
			continue
		(index, max_i) = ((index + min_i) // 2, index)

def f(N):

	def g(i):
		if i < I or J < i:
			return i * (N - i + 1)
		elif i == I:
			return 0
		elif I < J:
			return i * (N - i + 2)
		else:
			return i * (N - i)
	(I, J) = (A, N - B + 1)
	return max(g(N // 2), g(N // 2 + 1), g(N // 2 + 2))
(Q,) = list(map(int, input().split()))
for _ in range(Q):
	(A, B) = list(map(int, input().split()))
	r = bsearch(A * B, 1, A * B, f)
	print(r - 1)


from math import sqrt
Q = int(input())
for i in range(Q):
	(A, B) = map(int, input().split())
	m = A * B
	C = int(sqrt(m))
	if C * C == m:
		C = C - 1
	if A == B or B == A + 1:
		ans = 2 * A - 2
	elif A == B + 1:
		ans = 2 * B - 2
	elif C * (C + 1) < m:
		ans = 2 * C - 1
	else:
		ans = 2 * C - 2
	print(ans)


from math import sqrt
Q = int(input())
for i in range(Q):
	(a, b) = map(int, input().split())
	if not a < b:
		(a, b) = (b, a)
	if a == b or a + 1 == b:
		print(2 * a - 2)
		continue
	c = int(sqrt(a * b))
	if c ** 2 == a * b:
		c -= 1
	if c * (c + 1) >= a * b:
		print(2 * c - 2)
		continue
	print(2 * c - 1)


import math
Q = int(input())
for roop in range(Q):
	(X, Y) = list(map(int, input().split()))
	A = min([X, Y])
	B = max([X, Y])
	if A == B:
		print(2 * A - 2)
	elif A + 1 == B:
		print(2 * A - 2)
	else:
		C = int(math.sqrt(A * B))
		while True:
			if C ** 2 >= A * B:
				C -= 1
			elif (C + 1) ** 2 < A * B:
				C += 1
			else:
				break
		if C * (C + 1) >= A * B:
			print(2 * C - 2)
		else:
			print(2 * C - 1)


import math
time = int(input())

def check(a, b):
	num = a * b
	count = 0
	r = math.sqrt(num)
	r = int(r)
	if num == r ** 2:
		count = r
	else:
		count = r + 1
	if a == b:
		return count * 2 - 2
	elif a * b == count ** 2:
		return count * 2 - 3
	elif a * b > count * (count - 1):
		return count * 2 - 3
	else:
		return count * 2 - 4
for i in range(time):
	(a, b) = list(map(int, input().split()))
	print(check(a, b))


from math import sqrt
Q = int(input())
table = []
for i in range(Q):
	(A, B) = map(int, input().split())
	if A > B:
		table.append([B, A])
	else:
		table.append([A, B])

def f(a, b):
	if a == b:
		return 2 * a - 2
	if a + 1 == b:
		return 2 * a - 2
	m = int(sqrt(a * b))
	if m ** 2 == a * b:
		m -= 1
	if m * (m + 1) >= a * b:
		return 2 * m - 2
	return 2 * m - 1
ans = []
for (a, b) in table:
	ans.append(f(a, b))
print('\n'.join(map(str, ans)))


def isqrt(n):
	L = 0
	R = n
	while R - L > 2:
		M = (L + R) // 2
		if M * M == n:
			return M
		elif M * M < n:
			L = M
		else:
			R = M
	for ans in range(R, L - 1, -1):
		if ans * ans <= n:
			return ans
	assert False
	return -1

def count(n, A, B):
	ans = 0
	limit = isqrt(n)
	return max(0, limit - A) + min(n // (limit + 1), B - 1)
for _ in range(int(input())):
	(A, B) = map(int, input().split())
	print(count(A * B - 1, A, B) + count(A * B - 1, B, A))


q = int(input())
for it in range(q):
	(a, b) = list(map(int, input().split()))
	if a * b <= 2:
		print(0)
		continue
	(lo, hi) = (1, a * b - 1)
	while lo < hi:
		x = (lo + hi + 1) // 2
		if x % 2 == 0:
			(r1, r2) = (x // 2, x // 2 + 1)
			(l1, l2) = (x // 2, x // 2 + 1)
		else:
			(l, r) = ((x + 1) // 2, (x + 1) // 2)
			if a <= l:
				l += 1
			if b <= r:
				r += 1
			if l * r < a * b:
				lo = x
			else:
				hi = x - 1
			continue
		if b <= r1:
			r1 += 1
			r2 += 1
		if a <= l1:
			l1 += 1
			l2 += 1
		if l1 * r2 < a * b and l2 * r1 < a * b:
			lo = x
		else:
			hi = x - 1
	print(lo)


import math

def slv(A, B):
	(A, B) = (A, B) if A > B else (B, A)
	s = A * B
	c = math.floor(math.sqrt(A * B))
	if c * (c + 1) < s:
		return 2 * c - 1
	elif A == B:
		return 2 * c - 2
	elif c * c < s:
		return 2 * c - 2
	elif c * (c - 1) < s:
		return 2 * c - 3
Q = int(input())
for q in range(Q):
	(A, B) = map(int, input().split())
	print(slv(A, B))


Q = int(input())
import math
for i in range(Q):
	(a, b) = map(int, input().split())
	if a == b:
		print(2 * (a - 1))
	else:
		d = math.isqrt(a * b - 1)
		if d * (d + 1) < a * b:
			print(2 * d - 1)
		else:
			print(2 * d - 2)


from math import *
Q = int(input())
r = []
for x in range(Q):
	A = [int(i) for i in input().split(' ')]
	x = A[0] * A[1]
	s = floor(sqrt(x))
	if s * s == x:
		if A[0] != s:
			r.append(2 * s - 3)
		else:
			r.append(2 * s - 2)
	elif s * (s + 1) < x:
		r.append(2 * s - 1)
	else:
		r.append(2 * s - 2)
for i in r:
	print(i)


import math
q = int(input())
for i in range(q):
	(a, b) = list(map(int, input().split()))
	c = int(math.sqrt(a * b))
	ans = 2 * (c - 1)
	if (a * b - 1) // c > c:
		ans += 2
	elif a * b == c * c:
		pass
	else:
		ans += 1
	if not a == b == c:
		ans -= 1
	print(max(0, ans))


from math import ceil
q = int(input())
for _ in range(q):
	(a, b) = sorted(map(int, input().split()))
	print(min(b - a, max((ceil((a * b) ** 0.5 - a) - 1) * 2, (ceil((-(2 * a - 1) + (1 + 4 * a * b) ** 0.5) / 2) - 1) * 2 - 1, 0)) + 2 * (a - 1))


from math import ceil, sqrt
Q = int(input())
for i in range(Q):
	(A, B) = sorted(map(int, input().split(' ')))
	s = A * B
	if A == B:
		print(2 * A - 2)
	elif A == B + 1:
		print(2 * A - 2)
	else:
		C = ceil(sqrt(s)) - 1
		if C * (C + 1) >= s:
			print(2 * C - 2)
		else:
			print(2 * C - 1)


import math
n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split()))
	c = a * b
	r = int(math.sqrt(c))
	if a == b:
		print((r - 1) * 2)
	elif r ** 2 == c:
		print((r - 1) * 2 - 1)
	elif r * (r + 1) < c:
		print(r * 2 - 1)
	else:
		print((r - 1) * 2)


import math
Q = int(input())
for _ in range(Q):
	(A, B) = list(map(int, input().split()))
	if A < B:
		(A, B) = (B, A)
	S = A * B
	a = math.floor(math.sqrt(S - 1))
	if a * a > S - 1:
		a -= 1
	if A - B <= 1:
		print(2 * (B - 1))
	elif a * (a + 1) < S:
		print(B - 1 + a + max(0, a - B))
	else:
		print(B - 1 + a + max(0, a - B - 1))


def main():
	n = int(input())
	for _ in range(n):
		(a, b) = map(int, input().split())
		ref = a * b
		s = int(ref ** 0.5)
		ans = 2 * s - 1
		if s * (s + 1) >= ref:
			ans -= 1
		if s * s == ref and a != b:
			ans -= 1
		print(ans)

def __starting_point():
	main()
__starting_point()


q = int(input())
for i in range(q):
	(a, b) = list(map(int, input().split()))
	p = int((a * b - 1) ** 0.5)
	if p * p > a * b - 1:
		p = p - 1
	r = p * 2 - 1
	if p * p + p > a * b - 1:
		r = r - 1
	if a == b:
		r = r + 1
	print(r)


n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split()))
	if a == b:
		print(2 * a - 2)
	else:
		c = int((a * b) ** (1 / 2))
		if c * c == a * b:
			c -= 1
		if c * c + c >= a * b:
			print(2 * c - 2)
		else:
			print(2 * c - 1)


from math import sqrt
q = int(input())
for _ in range(q):
	(a, b) = list(map(int, input().split()))
	m = a * b
	s = int(sqrt(m))
	ans = 2 * s - 1
	if s * (s + 1) >= m:
		ans -= 1
	if s * s == m and a != b:
		ans -= 1
	print(ans)


import sys
input = sys.stdin.readline

def solve(a, b):
	score = a * b
	(l, r) = (0, int(1e+18))
	while r - l > 1:
		k = (l + r) // 2
		if k ** 2 < score:
			l = k
		else:
			r = k
	ans1 = l * 2 - 1
	if a <= l:
		ans1 -= 1
	if b <= l and a != b:
		ans1 -= 1
	ans2 = 0
	if l * r < a * b:
		ans2 = l * 2
		if a <= l:
			ans2 -= 1
		if b <= l and a + b != l + r:
			ans2 -= 1
	ans = max(ans1, ans2)
	return ans

def main():
	q = int(input())
	for i in range(q):
		(a, b) = list(map(int, input().split()))
		ans = solve(a, b)
		print(ans)

def __starting_point():
	main()
__starting_point()


import math
Q = int(input())
Query = []
for i in range(Q):
	Query.append(tuple(map(int, input().split())))
for (a, b) in Query:
	sq = int(math.sqrt(a * b))
	ans = sq * 2 - 1
	if a == b:
		ans -= 1
	elif sq ** 2 == a * b:
		ans -= 2
	elif sq * (sq + 1) >= a * b:
		ans -= 1
	print(ans)


from math import sqrt
for i in range(int(input())):
	(a, b) = list(map(int, input().split()))
	if not a < b:
		(a, b) = (b, a)
	ans = (a - 1) * 2 + (a < b - 1)
	c = int(sqrt(a * b))
	if c ** 2 == a * b:
		c -= 1
	if a < c:
		if a * b % c == 0:
			d = a * b // c - 1
		else:
			d = a * b // c
		ans += (c - a) * 2 - (c == d)
	print(ans)


q = int(input())
for i in range(q):
	(a, b) = list(map(int, input().split()))
	left = 0
	right = a * b
	for i in range(100):
		mid = (left + right) // 2
		if mid * mid < a * b:
			left = mid
		else:
			right = mid
	ret = left * 2
	if ret == 0:
		print(ret)
		continue
	if (a * b - 1) // left == left:
		ret -= 1
	if min(a, b) <= left:
		ret -= 1
	print(ret)


from math import sqrt
q = int(input())
for _ in range(q):
	(a, b) = map(int, input().split())
	t = a * b
	s = int(sqrt(t))
	an = 2 * s - 2
	if s * s == t:
		an -= 1
	if s * (s + 1) < t:
		an += 1
	if a == b:
		an += 1
	print(an)


import sys
readline = sys.stdin.readline
read = sys.stdin.read

def isqrt(x):
	ok = 0
	ng = 10 ** 9 + 1
	while ng - ok > 1:
		mid = (ok + ng) // 2
		if mid ** 2 <= x:
			ok = mid
		else:
			ng = mid
	return ok

def solve(a, b):
	ab = a * b
	if ab == 1:
		return 0
	x = isqrt(a * b - 1)
	if x * (x + 1) < ab:
		res = 2 * x
	else:
		res = 2 * x - 1
	if x >= min(a, b):
		res -= 1
	return res
q = int(readline())
for _ in range(q):
	(a, b) = list(map(int, readline().split()))
	print(solve(a, b))


import sys
input = sys.stdin.readline
Q = int(input())

def max_score(x, a):
	ret = 0
	for p in [x - 4, x - 2, x, x + 2, x + 4]:
		p += x % 2
		p //= 2
		ret = max(ret, (p + (p >= a)) * (x - p + 1))
	return ret
for _ in range(Q):
	(a, b) = list(map(int, input().split()))
	(a, b) = (min(a, b), max(a, b))

	def is_ok(x):
		return a * b > max_score(x, a)

	def bisect(ng, ok):
		while abs(ok - ng) > 1:
			mid = (ok + ng) // 2
			if is_ok(mid):
				ok = mid
			else:
				ng = mid
		return ok
	ans = bisect(2 * b + 1, a - 1)
	print(ans)


import sys

def solve(a, b):
	ans = 0
	cur = int(a * b)
	left = 1
	right = cur + 1
	while left < right:
		mid = int((left + right) / 2)
		z = int(mid / 2)
		mx = z * (mid - z)
		if mx <= cur:
			ans = mid
			left = mid + 1
		else:
			right = mid
	if int(ans / 2) * (ans - int(ans / 2)) == cur and a != b:
		ans -= 1
	return ans
n = int(sys.stdin.readline())
for i in range(n):
	x = sys.stdin.readline()
	y = [int(z) for z in x.split()]
	print(max(int(solve(y[0], y[1])) - 2, 0))


import math
n = int(input())
for i in range(n):
	ans = 0
	(a, b) = map(int, input().split())
	c = a * b
	d = int(math.sqrt(c))
	if d * d == c:
		d -= 1
	ans += d * 2
	if d >= a:
		ans -= 1
	if d >= b:
		ans -= 1
	if d * (d + 1) >= c:
		ans -= 1
	print(ans)


Q = int(input())
E = 10 ** (-10)
from math import floor

def f(x):
	if min(abs(int(x) - x), abs(int(x) + 1 - x)) < E:
		return int(x - 1)
	else:
		return int(x)
for i in range(Q):
	(a, b) = list(map(int, input().split()))
	n = a * b
	if f(n ** (1 / 2)) < a and f(n ** (1 / 2)) < b:
		if f(n ** (1 / 2)) * (f(n ** (1 / 2)) + 1) < n:
			print(2 * f(n ** (1 / 2)))
		else:
			print(2 * f(n ** (1 / 2)) - 1)
	elif f(n ** (1 / 2)) * (f(n ** (1 / 2)) + 1) < n:
		print(2 * f(n ** (1 / 2)) - 1)
	else:
		print(2 * f(n ** (1 / 2)) - 2)


from math import sqrt
q = int(input())
while q:
	(a, b) = map(int, input().split())
	c = a * b
	d = int(sqrt(c))
	if a == b:
		print((d - 1) * 2)
	elif d * d == c:
		print((d - 1) * 2 - 1)
	elif d * (d + 1) < c:
		print(d * 2 - 1)
	else:
		print((d - 1) * 2)
	q -= 1


Q = int(input())
for i in range(Q):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if b in (a, a + 1):
		print((a - 1) * 2)
		continue
	c = int((a * b) ** 0.5)
	if c * c == a * b:
		c -= 1
	ans = 2 * c - 2
	if c * (c + 1) < a * b:
		ans += 1
	print(ans)


def check(k, a, b):
	i = (k - a) // 2
	return -(i + a) * (i - k) < a * b
q = int(input())
for i in range(q):
	(a, b) = map(int, input().split())
	if a == b:
		print(2 * a - 2)
		continue
	(a, b) = sorted([a, b])
	ans = a - 1
	left = a
	right = 10 ** 9
	while right - left > 1:
		mid = (right + left) // 2
		if check(mid, a, b):
			left = mid
		else:
			right = mid
	ans += left - 1
	print(ans)


import math

def solve(a, b):
	(a, b) = (min(a, b), max(a, b))
	if a == b:
		return 2 * a - 2
	c = int(math.sqrt(a * b)) + 2
	while True:
		if c * c < a * b:
			if c * (c + 1) >= a * b:
				return 2 * c - 2
			else:
				return 2 * c - 1
		else:
			c -= 1
Q = int(input())
for _ in range(Q):
	(a, b) = list(map(int, input().split()))
	print(solve(a, b))