#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("-ffloat-store")
using namespace std;
clock_t time_p = clock();
void aryanc403() {}
const long long int INF = 0xFFFFFFFFFFFFFFFL;
long long int seed;
mt19937 rng(seed = chrono::steady_clock::now().time_since_epoch().count());
inline long long int rnd(long long int l = 0, long long int r = INF) {
  return uniform_int_distribution<long long int>(l, r)(rng);
}
class CMP {
 public:
  bool operator()(pair<long long int, long long int> a,
                  pair<long long int, long long int> b) {
    return !(a.first < b.first || (a.first == b.first && a.second <= b.second));
  }
};
void add(map<long long int, long long int> &m, long long int x,
         long long int cnt = 1) {
  auto jt = m.find(x);
  if (jt == m.end())
    m.insert({x, cnt});
  else
    jt->second += cnt;
}
void del(map<long long int, long long int> &m, long long int x,
         long long int cnt = 1) {
  auto jt = m.find(x);
  if (jt->second <= cnt)
    m.erase(jt);
  else
    jt->second -= cnt;
}
bool cmp(const pair<long long int, long long int> &a,
         const pair<long long int, long long int> &b) {
  return a.first < b.first || (a.first == b.first && a.second < b.second);
}
const long long int mod = 1000000007L;
long long int T, n, i, j, k, in, cnt, l, r, u, v, x, y;
long long int m;
string s;
vector<long long int> a;
long long int sod(long long int n) {
  if (n < 0) return -INF;
  if (n == 0) return 0;
  return sod(n / 10) + n % 10;
}
long long int sqt(long long int n) {
  if (n < 0) return INF;
  long long int c = sqrt(n);
  ;
  while (c * c < n) c++;
  while (c * c > n) c--;
  if (c * c != n) return INF;
  return c;
}
long long int solve(long long int b, long long int v) {
  long long int c = sqt(b * b + 4 * v);
  if (c == INF || (b + c) % 2) return INF;
  long long int x = -b - c, y = -b + c;
  x /= 2;
  y /= 2;
  if (x > 0 && sod(x) == b) return x;
  if (y > 0 && sod(y) == b) return y;
  return INF;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  {
    cin >> n;
    long long int ans = INF;
    for (i = (0); i <= (18 * 9); ++i) ans = min(ans, solve(i, n));
    if (ans == INF) ans = -1;
    cout << ans << "\n";
  }
  aryanc403();
  return 0;
}

### Prompt

Please create a solution in Cpp to the following problem:

Let's consider equation:

x2 + s(x)·x - n = 0, 

where x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.

You are given an integer n, find the smallest positive integer root of equation x, or else determine that there are no such roots.

Input

A single line contains integer n (1 ≤ n ≤ 1018) — the equation parameter.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier. 

Output

Print -1, if the equation doesn't have integer positive roots. Otherwise print such smallest integer x (x > 0), that the equation given in the statement holds.

Examples

Input

2


Output

1


Input

110


Output

10


Input

4


Output

-1

Note

In the first test case x = 1 is the minimum root. As s(1) = 1 and 12 + 1·1 - 2 = 0.

In the second test case x = 10 is the minimum root. As s(10) = 1 + 0 = 1 and 102 + 1·10 - 110 = 0.

In the third test case the equation has no roots.

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("-ffloat-store")
using namespace std;
clock_t time_p = clock();
void aryanc403() {}
const long long int INF = 0xFFFFFFFFFFFFFFFL;
long long int seed;
mt19937 rng(seed = chrono::steady_clock::now().time_since_epoch().count());
inline long long int rnd(long long int l = 0, long long int r = INF) {
  return uniform_int_distribution<long long int>(l, r)(rng);
}
class CMP {
 public:
  bool operator()(pair<long long int, long long int> a,
                  pair<long long int, long long int> b) {
    return !(a.first < b.first || (a.first == b.first && a.second <= b.second));
  }
};
void add(map<long long int, long long int> &m, long long int x,
         long long int cnt = 1) {
  auto jt = m.find(x);
  if (jt == m.end())
    m.insert({x, cnt});
  else
    jt->second += cnt;
}
void del(map<long long int, long long int> &m, long long int x,
         long long int cnt = 1) {
  auto jt = m.find(x);
  if (jt->second <= cnt)
    m.erase(jt);
  else
    jt->second -= cnt;
}
bool cmp(const pair<long long int, long long int> &a,
         const pair<long long int, long long int> &b) {
  return a.first < b.first || (a.first == b.first && a.second < b.second);
}
const long long int mod = 1000000007L;
long long int T, n, i, j, k, in, cnt, l, r, u, v, x, y;
long long int m;
string s;
vector<long long int> a;
long long int sod(long long int n) {
  if (n < 0) return -INF;
  if (n == 0) return 0;
  return sod(n / 10) + n % 10;
}
long long int sqt(long long int n) {
  if (n < 0) return INF;
  long long int c = sqrt(n);
  ;
  while (c * c < n) c++;
  while (c * c > n) c--;
  if (c * c != n) return INF;
  return c;
}
long long int solve(long long int b, long long int v) {
  long long int c = sqt(b * b + 4 * v);
  if (c == INF || (b + c) % 2) return INF;
  long long int x = -b - c, y = -b + c;
  x /= 2;
  y /= 2;
  if (x > 0 && sod(x) == b) return x;
  if (y > 0 && sod(y) == b) return y;
  return INF;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  {
    cin >> n;
    long long int ans = INF;
    for (i = (0); i <= (18 * 9); ++i) ans = min(ans, solve(i, n));
    if (ans == INF) ans = -1;
    cout << ans << "\n";
  }
  aryanc403();
  return 0;
}

```