import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
 
		int sum = 0;
		for(int i=0; i != 1001; i++){
			for(int n = i; n != 0; n /= 10){ 
				sum += (n % 10); }
 
            if(i%3 == 0 & i%5 != 0 & sum<10){
                System.out.println(i);
            }
            sum = 0;
		}
 
	}
}