# 大整数开根 codevs3119

## Code

#include <stdio.h>
#include <string.h>
#define rep(i, st, ed) for (int i = st; i <= ed; i += 1)
#define drp(i, st, ed) for (int i = st; i >= ed; i -= 1)
#define fill(x, t) memset(x, t, sizeof(x))
#define max(x, y) ((x)>(y)?(x):(y))
#define L 1001
#define MOD 1000
struct num{
int s[L], len;
inline bool operator ==(num b){
num a = *this;
if (a.len != b.len){
return 0;
}else{
drp(i, a.len, 1){
if (a.s[i] != b.s[i]){
return 0;
}
}
return 1;
}
}
inline bool operator <(num b){
num a = *this;
if (a.len < b.len){
return 1;
}else if (a.len > b.len){
return 0;
}else{
drp(i, a.len, 1){
if (a.s[i] < b.s[i]){
return 1;
}else if (a.s[i] > b.s[i]){
return 0;
}
}
return 0;
}
}
inline bool operator <=(num b){
num a = *this;
if (a < b || a == b){
return 1;
}else{
return 0;
}
}
inline bool operator >(num b){
num a = *this;
if (a.len > b.len){
return 1;
}else if (a.len < b.len){
return 0;
}else{
drp(i, a.len, 1){
if (a.s[i] > b.s[i]){
return 1;
}else if (a.s[i] < b.s[i]){
return 0;
}
}
return 0;
}
}
inline bool operator >=(num b){
num a = *this;
if (a > b || a == b){
return 1;
}else{
return 0;
}
}
inline num operator +(num b){
num a = *this, c = (num){{0}, max(a.len, b.len)};
int v = 0;
rep(i, 1, c.len){
c.s[i] = (a.s[i] + b.s[i] + v) % MOD;
v = (a.s[i] + b.s[i] + v) / MOD;
}
if (v){
c.len += 1;
c.s[c.len] = v;
}
return c;
}
inline num operator -(num b){
num a = *this, c = (num){{0}, max(a.len, b.len)};
rep(i, 1, c.len){
c.s[i] = a.s[i] - b.s[i];
if (c.s[i] < 0){
c.s[i] += MOD;
a.s[i + 1] -= 1;
}
}
while (!c.s[c.len] && c.len > 1){
c.len -= 1;
}
return c;
}
inline num operator *(num b){
num a = *this, c = (num){{0}, a.len + b.len};
rep(i, 1, a.len){
rep(j, 1, b.len){
c.s[i + j - 1] += a.s[i] * b.s[j];
}
}
rep(i, 1, a.len + b.len){
c.s[i + 1] += c.s[i] / MOD;
c.s[i] %= MOD;
}
while (!c.s[c.len] && c.len > 1){
c.len -= 1;
}
return c;
}
inline num operator /(int b){
num a = *this, c = (num){{0}, a.len};
int v = 0;
drp(i, len, 1){
int t = v * MOD + a.s[i];
c.s[i] = t / b;
v = t % b;
}
while (!c.s[c.len] && c.len > 1){
c.len -= 1;
}
return c;
}
fill(s, 0); len = 0;
char st[L];
scanf("%s", st);
int v = 0, i;
for (i = strlen(st) - 1; i >= 3; i -= 3){
rep(j, i - 2, i){
v = v * 10 + st[j] - '0';
}
s[++ len] = v;
v = 0;
}
rep(j, 0, i){
v = v * 10 + st[j] - '0';
}
s[++ len] = v;
}
fill(s, 0);
len = 0;
do{s[++ len] = x % MOD;}while (x /= MOD);
}
inline void output(){
num tmp = *this;
int i = tmp.len;
while (!tmp.s[i] && i > 1){
i -= 1;
}
printf("%d", tmp.s[i]);
drp(j, i - 1, 1){
int v = tmp.s[j];
int f[5] = {0};
rep(k, 1, 3){
f[k] = v % 10;
v /= 10;
}
drp(k, 3, 1){
printf("%d", f[k]);
}
}
printf("\n");
}
};
num one;
int main(void){
one.s[1] = 1;
one.len = 1;
num p;
num r = p;
num l; l.s[1] = 0; l.len = 1;
num mid, ans;
while (l <= r){
mid = l + r;
mid = mid / 2;
num qr = mid * mid;
if (qr <= p){
l = mid + one;
ans = mid;
}else if (qr > p){
r = mid - one;
}
}
ans.output();
return 0;
}