#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	int g,s,b;
	for(n=1;n<=999;n++){
		g=n%10;
		s=n/10%10;
		b=n/100;	
		
		if( n%3==0&&(g==5||s==5||b==5))cout<<n<<endl;
	}
	

	return 0;
}

/**************************************************************
	Problem: 1059
	User: chenxuanyi
	Language: C++
	Result: Accepted
	Time:9 ms
	Memory:2072 kb
****************************************************************/