/* package whatever; // don't place package name! */

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
	{
		int sum = 0;
		int x = 0;
		
		for (int i = 0; i < 1001; i++)
		{
			if (i % 3 == 0)
			{
				if (i % 5 != 0)
				{
					
					if (checkSum(i) < 10){
						System.out.println(i);
					}
				}
			}
		}
		
		
	}
	
	public static int checkSum (int x)
		{
			int sum = 0;
			while(x > 0) {
				sum += x % 10;
				x /= 10;
			}
			return sum;
		} 
}