PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000083. Căn bậc hai nguyên (Sqrt(x))

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Căn bậc hai nguyên (Sqrt(x))

Sqrt(x)

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

Given a nonnegative integer xx, find the largest nonnegative integer rr with r2≤xr^2\le x, without using built-in square-root or power functions.

Input

A single line contains xx.

Output

Print rr.

Subtasks

  • Subtask 1 (20 points): 0≤x≤10000\le x\le 1000.
  • Subtask 2 (30 points): 0≤x≤10000000\le x\le 1000000.
  • Subtask 3 (50 points): 0≤x≤21474836470\le x\le 2147483647.

Examples

Input

8

Output

2

Explanation

22=4≤82^2=4\le8 while 32=9>83^2=9>8. Therefore the integer square root is 22.