#include <bits/stdc++.h>
using namespace std;
bool IsOk(uint64_t x,uint64_t sum){
uint64_t tmp = 0;
while(x){
tmp += x;
x /= 10;
}
return tmp == sum;
}
uint64_t func(uint64_t sum){
int digits = 0;
uint64_t tmp = sum;
while(tmp){
++digits;
tmp /= 10;
}
string molecule = "1" + string(digits - 1,'0');
string denominator(digits,'1');
uint64_t ret = (stoull(molecule) * 10 / stoull(denominator)) * sum / 10;
for(uint64_t i = 1;i <= 10;++i){
if(IsOk(ret + i,sum))
return ret + i;
if(IsOk(ret - i,sum))
return ret - i;
}
uint64_t special = 101002030405;
return special;
}
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);
uint64_t n;
cin >> n;
uint64_t special = 101002030405;
if(func(n) != special)
cout<<func(n)<<endl;
else
cout<<-1<<endl;
return 0;
}