AtCoder Beginner Contest 144
C
Walk on Multiplication Table
AtCoder
⌀ 311
原题
← BD →
翻译中…

Problem Statement

翻译中…

Takahashi is standing on a multiplication table with infinitely many rows and columns.

翻译中…

The square $(i,j)$ contains the integer $i \times j$. Initially, Takahashi is standing at $(1,1)$.

翻译中…

In one move, he can move from $(i,j)$ to either $(i+1,j)$ or $(i,j+1)$.

翻译中…

Given an integer $N$, find the minimum number of moves needed to reach a square that contains $N$.

翻译中…

Constraints

翻译中…
  • $2 \leq N \leq 10^{12}$
  • $N$ is an integer.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N

翻译中…

Output

翻译中…

Print the minimum number of moves needed to reach a square that contains the integer $N$.

翻译中…

样例

Input #1
10
Output #1
5
$(2,5)$ can be reached in five moves. We cannot reach a square that contains $10$ in less than five moves.
Input #2
50
Output #2
13
$(5, 10)$ can be reached in $13$ moves.
Input #3
10000000019
Output #3
10000000018
Both input and output may be enormous.
题目信息
题号
abc144_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。