import java.util.Scanner; 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w;
        int t;
        for(int c=1;c<=h;c++){
            t = c;
            w = c%3;
            if(w==0){
                System.out.print(" "+c);
            }else{
                while(t!=0){
                    if(t%10==3){
                        System.out.print(" "+c);break;
                    }else{
                        t/= 10;
                    }
                    
                }
            }
        }
      System.out.println();  
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w;
        int t;
        for(int c=1;c<=h;c++){
            t = c;
            w = c%3;
            if(w==0){
                System.out.print(" "+c);
            }else{
                while(t!=0){
                    if(t%10==3){
                        System.out.print(" "+c);break;
                    }else{
                        t/= 10;
                    }
                    
                }
            }
        }
      System.out.println();  
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w;
        int t;
        for(int c=1;c<=h;c++){
            t = c;
            w = c%3;
            if(w==0){
                System.out.print(" "+c);
            }else{
                while(t!=0){
                    if(t%10==3){
                        System.out.print(" "+c);break;
                    }else{
                        t/= 10;
                    }
                    
                }
            }
        }
      System.out.println();  
    } main {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w;
        int t;
        for(int c=1;c<=h;c++){
            t = c;
            w = c%3;
            if(w==0){
                System.out.print(" "+c);
            }else{
                while(t!=0){
                    if(t%10==3){
                        System.out.print(" "+c);break;
                    }else{
                        t/= 10;
                    }
                    
                }
            }
        }
      System.out.println();  
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc int w; w int t; t for(int c=1;c<=h;c++){
            t = c;
            w = c%3;
            if(w==0){
                System.out.print(" "+c);
            }else{
                while(t!=0){
                    if(t%10==3){
                        System.out.print(" "+c);break;
                    }else{
                        t/= 10;
                    }
                    
                }
            }
        } int c=1; int c=1; c 1 c<=h c h c++ c++ c {
            t = c;
            w = c%3;
            if(w==0){
                System.out.print(" "+c);
            }else{
                while(t!=0){
                    if(t%10==3){
                        System.out.print(" "+c);break;
                    }else{
                        t/= 10;
                    }
                    
                }
            }
        } {
            t = c;
            w = c%3;
            if(w==0){
                System.out.print(" "+c);
            }else{
                while(t!=0){
                    if(t%10==3){
                        System.out.print(" "+c);break;
                    }else{
                        t/= 10;
                    }
                    
                }
            }
        } t = c t c w = c%3 w c%3 c 3 if(w==0){
                System.out.print(" "+c);
            }else{
                while(t!=0){
                    if(t%10==3){
                        System.out.print(" "+c);break;
                    }else{
                        t/= 10;
                    }
                    
                }
            } w==0 w 0 {
                System.out.print(" "+c);
            } System.out.print(" "+c) System.out.print System.out System System.out " "+c " " c {
                while(t!=0){
                    if(t%10==3){
                        System.out.print(" "+c);break;
                    }else{
                        t/= 10;
                    }
                    
                }
            } while(t!=0){
                    if(t%10==3){
                        System.out.print(" "+c);break;
                    }else{
                        t/= 10;
                    }
                    
                } t!=0 t 0 {
                    if(t%10==3){
                        System.out.print(" "+c);break;
                    }else{
                        t/= 10;
                    }
                    
                } if(t%10==3){
                        System.out.print(" "+c);break;
                    }else{
                        t/= 10;
                    } t%10==3 t%10 t 10 3 {
                        System.out.print(" "+c);break;
                    } System.out.print(" "+c) System.out.print System.out System System.out " "+c " " c break; {
                        t/= 10;
                    } t/= 10 t 10 System.out.println() System.out.println System.out System System.out String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w;
        int t;
        for(int c=1;c<=h;c++){
            t = c;
            w = c%3;
            if(w==0){
                System.out.print(" "+c);
            }else{
                while(t!=0){
                    if(t%10==3){
                        System.out.print(" "+c);break;
                    }else{
                        t/= 10;
                    }
                    
                }
            }
        }
      System.out.println();  
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w;
        int t;
        for(int c=1;c<=h;c++){
            t = c;
            w = c%3;
            if(w==0){
                System.out.print(" "+c);
            }else{
                while(t!=0){
                    if(t%10==3){
                        System.out.print(" "+c);break;
                    }else{
                        t/= 10;
                    }
                    
                }
            }
        }
      System.out.println();  
    }
} Main
import java.util.Scanner; 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w;
        int t;
        for(int c=1;c<=h;c++){
            t = c;
            w = c%3;
            if(w==0){
                System.out.print(" "+c);
            }else{
                while(t!=0){
                    if(t%10==3){
                        System.out.print(" "+c);break;
                    }else{
                        t/= 10;
                    }
                    
                }
            }
        }
      System.out.println();  
    }
}
