#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,i=1,w=0,j=0;
	cin>>n;
	while(i<=n){
		j=i;
		while(j>0){
			w=j%10;
			j=j/10;
			if(w==3||w==5){
				if(i%2==0){
					cout<<i<<endl;
				}
			}
		}
		i=i+1;
	}
}


/**************************************************************
	Problem: 1714
	User: 15159808820
	Language: C++
	Result: Accepted
	Time:8 ms
	Memory:2072 kb
****************************************************************/