#include <bits/stdc++.h>
using namespace std;
int sum(int x) {
int s = 0;
while (x) { s += x % 10; x /= 10; }
return s;
}
int zys_sum(int x) {
int s = 0, tmp = x;
for (int j = 2; j <= tmp; ++j) {
while (tmp % j == 0) {
int t = j;
while (t) { s += t % 10; t /= 10; }
tmp /= j;
}
}
return s;
}
bool ss(int x){
if(x<2){
return false;
}else{
for(int i=2 ; i*i<=x ; i++){
if(x%i==0){
return false;
}
}
return true;
}
}
int main() {
int n, num = 0;
cin >> n;
for (int i = 1; i <= n; ++i) {
if(!ss(i) && sum(i)==zys_sum(i)){
//cout<<"数"<<i<<" 和:"<<sum(i)<<" "<<"质因数和:"<<zys_sum(i)<<endl;
num++;
cout<<i;
if(num%5!=0)cout<<" ";
else cout<<endl;
}
}
return 0;
}
/**************************************************************
Problem: 1875
User: admin
Language: C++
Result: Accepted
Time:235 ms
Memory:2072 kb
****************************************************************/