import java.util.Scanner;
class Main {
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
			int numN = scanner.nextInt();
			int numn;
			
            for(numn = 3; numn <= numN; numn++){

            	if (numn % 3 == 0){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 100 / 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 1000 / 100 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10000 / 1000 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn / 10000 == 3){
            		System.out.print(" "+numn);
            	}
            	else{
            	}
            }
            System.out.println();
	}
} import java.util.Scanner; Scanner java.util class Main {
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
			int numN = scanner.nextInt();
			int numn;
			
            for(numn = 3; numn <= numN; numn++){

            	if (numn % 3 == 0){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 100 / 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 1000 / 100 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10000 / 1000 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn / 10000 == 3){
            		System.out.print(" "+numn);
            	}
            	else{
            	}
            }
            System.out.println();
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
			int numN = scanner.nextInt();
			int numn;
			
            for(numn = 3; numn <= numN; numn++){

            	if (numn % 3 == 0){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 100 / 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 1000 / 100 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10000 / 1000 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn / 10000 == 3){
            		System.out.print(" "+numn);
            	}
            	else{
            	}
            }
            System.out.println();
	} main {
		Scanner scanner = new Scanner(System.in);
		
			int numN = scanner.nextInt();
			int numn;
			
            for(numn = 3; numn <= numN; numn++){

            	if (numn % 3 == 0){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 100 / 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 1000 / 100 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10000 / 1000 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn / 10000 == 3){
            		System.out.print(" "+numn);
            	}
            	else{
            	}
            }
            System.out.println();
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int numN = scanner.nextInt(); numN scanner.nextInt() scanner.nextInt scanner int numn; numn for(numn = 3; numn <= numN; numn++){

            	if (numn % 3 == 0){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 100 / 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 1000 / 100 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10000 / 1000 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn / 10000 == 3){
            		System.out.print(" "+numn);
            	}
            	else{
            	}
            } numn = 3; numn = 3 numn 3 numn <= numN numn numN numn++ numn++ numn {

            	if (numn % 3 == 0){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 100 / 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 1000 / 100 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10000 / 1000 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn / 10000 == 3){
            		System.out.print(" "+numn);
            	}
            	else{
            	}
            } {

            	if (numn % 3 == 0){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 100 / 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 1000 / 100 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10000 / 1000 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn / 10000 == 3){
            		System.out.print(" "+numn);
            	}
            	else{
            	}
            } if (numn % 3 == 0){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 100 / 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 1000 / 100 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10000 / 1000 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn / 10000 == 3){
            		System.out.print(" "+numn);
            	}
            	else{
            	} numn % 3 == 0 numn % 3 numn 3 0 {
            		System.out.print(" "+numn);
            	} System.out.print(" "+numn) System.out.print System.out System System.out " "+numn " " numn if(numn % 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 100 / 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 1000 / 100 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10000 / 1000 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn / 10000 == 3){
            		System.out.print(" "+numn);
            	}
            	else{
            	} numn % 10 == 3 numn % 10 numn 10 3 {
            		System.out.print(" "+numn);
            	} System.out.print(" "+numn) System.out.print System.out System System.out " "+numn " " numn if(numn % 100 / 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 1000 / 100 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10000 / 1000 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn / 10000 == 3){
            		System.out.print(" "+numn);
            	}
            	else{
            	} numn % 100 / 10 == 3 numn % 100 / 10 numn % 100 numn 100 10 3 {
            		System.out.print(" "+numn);
            	} System.out.print(" "+numn) System.out.print System.out System System.out " "+numn " " numn if(numn % 1000 / 100 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10000 / 1000 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn / 10000 == 3){
            		System.out.print(" "+numn);
            	}
            	else{
            	} numn % 1000 / 100 == 3 numn % 1000 / 100 numn % 1000 numn 1000 100 3 {
            		System.out.print(" "+numn);
            	} System.out.print(" "+numn) System.out.print System.out System System.out " "+numn " " numn if(numn % 10000 / 1000 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn / 10000 == 3){
            		System.out.print(" "+numn);
            	}
            	else{
            	} numn % 10000 / 1000 == 3 numn % 10000 / 1000 numn % 10000 numn 10000 1000 3 {
            		System.out.print(" "+numn);
            	} System.out.print(" "+numn) System.out.print System.out System System.out " "+numn " " numn if(numn / 10000 == 3){
            		System.out.print(" "+numn);
            	}
            	else{
            	} numn / 10000 == 3 numn / 10000 numn 10000 3 {
            		System.out.print(" "+numn);
            	} System.out.print(" "+numn) System.out.print System.out System System.out " "+numn " " numn {
            	} System.out.println() System.out.println System.out System System.out String[] args args
import java.util.Scanner;
class Main {
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
			int numN = scanner.nextInt();
			int numn;
			
            for(numn = 3; numn <= numN; numn++){

            	if (numn % 3 == 0){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 100 / 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 1000 / 100 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10000 / 1000 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn / 10000 == 3){
            		System.out.print(" "+numn);
            	}
            	else{
            	}
            }
            System.out.println();
	}
}