//Bai 11
#include<bits/stdc++.h>
using namespace std;
#define el "\n"
#define ll long long
#define ull unsigned long long
#define se second
#define fi first
#define be begin()
#define en end()
#define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
ll n;
void Run()
{
int ok = 0;
cin >> n;
// a^2 + 2a - n = 0
ll del = 2 * 2 - 4 * 1 * (-n);
if(del < 0) cout << "NO", ok = 1;
else
{
if(sqrt(del) * sqrt(del) != del) cout << "NO", ok = 1;
else
{
ll x1 = (-2 + sqrt(del)) / 2;
ll x2 = (-2 - sqrt(del)) / 2;
if(x1 * (x1 + 2) == n) cout << x1, ok = 1;
if(x2 * (x2 + 2) == n && ok == 0) cout << x2, ok = 1;
}
}
if(ok == 0) cout << "NO";
}
int main()
{
Faster;
Run();
return 0;
}
Ly9CYWkgMTEKCiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgZWwgIlxuIgojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIHVsbCB1bnNpZ25lZCBsb25nIGxvbmcKI2RlZmluZSBzZSBzZWNvbmQKI2RlZmluZSBmaSBmaXJzdAojZGVmaW5lIGJlIGJlZ2luKCkKI2RlZmluZSBlbiBlbmQoKQojZGVmaW5lIEZhc3RlciBjaW4udGllKDApOyBjb3V0LnRpZSgwKTsgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKbGwgbjsKdm9pZCBSdW4oKQp7CiAgICBpbnQgb2sgPSAwOwogICAgY2luID4+IG47CiAgICAvLyBhXjIgKyAyYSAtIG4gPSAwCiAgICBsbCBkZWwgPSAyICogMiAtIDQgKiAxICogKC1uKTsKICAgIGlmKGRlbCA8IDApIGNvdXQgPDwgIk5PIiwgb2sgPSAxOwogICAgZWxzZQogICAgewogICAgICAgIGlmKHNxcnQoZGVsKSAqIHNxcnQoZGVsKSAhPSBkZWwpIGNvdXQgPDwgIk5PIiwgb2sgPSAxOwogICA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