Accode:
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n,j=1,s=495;cin>>n;
if (n%495==0){cout<<-1;}
else
{
while (n%495!=0){n*=10;j*=10;
while (n>s) s+=495;if ((s-n)<j){cout<<s-n;break;}}
}
return 0;
}
over~