P25301 [AtCoder] Heyho and Addition
普及
题目描述

Problem Description

A square number is an integer that is the square of another integer. For example, $1$, $4$, $9$ are square numbers, but $2$, $6$ are not.

One day, Heyho found an integer $N$ on the street. Heyho loves square numbers and decided to obtain a square number by repeatedly performing the following operation:

  • Add $1$ to $N$.

Determine the minimum number of operations required for Heyho to obtain a square number.

Input Format

The input is given from the standard input in the following format:

$ N $

  • The first line contains the integer $N$ $(1 \leq N \leq 10,000)$ that Heyho found.

Output Format

Output the minimum number of operations required for Heyho to obtain a square number on a single line. Include a newline at the end of the output.

Sample Input and Output

Sample Input #1

7

Sample Output #1

2

Sample Input #2

16

Sample Output #2

0

Sample Input #3

82

Sample Output #3

18

Notes/Hints

Sample Explanation 1

By performing the operation twice, Heyho can obtain the square number $9$.

Sample Explanation 2

Since $16$ is already a square number, no operations are needed.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
7
样例输出
2