#include<bits/stdc++.h>
bool find_ans=0;
using namespace std;
const int n=9;
int main(){
int k;
cin>>k;
for(int a=1;a<=2;a++){
for(int b=1;b<=n;b++){
for(int c=1;c<=n;c++){
for(int d=1;d<=n;d++){
for(int e=1;e<=n;e++){
if((100*a+10*b+c)%k==0&&(100*b+10*c+d)%k==0&&(100*c+10*d+e)%k==0){
cout<<a<<b<<c<<d<<e<<endl;
find_ans=1;
}
}
}
}
}
}
if(30000%k==0){
cout<<30000;
find_ans=1;
}
if(!find_ans) cout<<"No";
return 0;
}