#include<bits/stdc++.h>
using namespace std;
int n,i=1,g,s,b;
int main(){
while(i<=999){
g=i%10;
s=i/10%10;
b=i/100%10;
if(i%3==0&&(g==5||s==5||b==5)) cout<<i<<endl;
i++;
}
return 0;
}
/**************************************************************
Problem: 1059
User: zhangziang
Language: C++
Result: Accepted
Time:6 ms
Memory:2072 kb
****************************************************************/