def func(n):
p = 0.618
i = 0
j = n
while i<=j:
mid = int(p*i + (1-p)*j)
if abs(mid*mid-n)<=abs((mid-1)*(mid-1)-n) and abs(mid*mid-n)<=abs((mid+1)*(mid+1)-n):
return mid
elif abs((mid-1)*(mid-1)-n)<=abs(mid*mid-n) and abs(mid*mid-n)<=abs((mid+1)*(mid+1)-n):
j = mid - 1
else:
i = mid + 1