import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        int n = scan.nextInt();
        int x = 1;
        int y = 0;
        if (n >= 3 && n <= 10000) {
            for (int count = 0;count < n; count++) {
                y = x / 10;
                if (x % 3 == 0){
                    sb.append(" ")
                        .append(x);
                } else {
                    y = x;
                    while(y != 0) {
                        if (y % 10 == 3) {
                            sb.append(" ")
                                .append(x);
                            break;
                        }
                        y /= 10;
                    }
                }
                x++;
            }
            System.out.println(sb);
        }
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        int n = scan.nextInt();
        int x = 1;
        int y = 0;
        if (n >= 3 && n <= 10000) {
            for (int count = 0;count < n; count++) {
                y = x / 10;
                if (x % 3 == 0){
                    sb.append(" ")
                        .append(x);
                } else {
                    y = x;
                    while(y != 0) {
                        if (y % 10 == 3) {
                            sb.append(" ")
                                .append(x);
                            break;
                        }
                        y /= 10;
                    }
                }
                x++;
            }
            System.out.println(sb);
        }
    }
} Main public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        int n = scan.nextInt();
        int x = 1;
        int y = 0;
        if (n >= 3 && n <= 10000) {
            for (int count = 0;count < n; count++) {
                y = x / 10;
                if (x % 3 == 0){
                    sb.append(" ")
                        .append(x);
                } else {
                    y = x;
                    while(y != 0) {
                        if (y % 10 == 3) {
                            sb.append(" ")
                                .append(x);
                            break;
                        }
                        y /= 10;
                    }
                }
                x++;
            }
            System.out.println(sb);
        }
    } main {
        Scanner scan = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        int n = scan.nextInt();
        int x = 1;
        int y = 0;
        if (n >= 3 && n <= 10000) {
            for (int count = 0;count < n; count++) {
                y = x / 10;
                if (x % 3 == 0){
                    sb.append(" ")
                        .append(x);
                } else {
                    y = x;
                    while(y != 0) {
                        if (y % 10 == 3) {
                            sb.append(" ")
                                .append(x);
                            break;
                        }
                        y /= 10;
                    }
                }
                x++;
            }
            System.out.println(sb);
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int x = 1; x 1 int y = 0; y 0 if (n >= 3 && n <= 10000) {
            for (int count = 0;count < n; count++) {
                y = x / 10;
                if (x % 3 == 0){
                    sb.append(" ")
                        .append(x);
                } else {
                    y = x;
                    while(y != 0) {
                        if (y % 10 == 3) {
                            sb.append(" ")
                                .append(x);
                            break;
                        }
                        y /= 10;
                    }
                }
                x++;
            }
            System.out.println(sb);
        } n >= 3 && n <= 10000 n >= 3 n 3 n <= 10000 n 10000 {
            for (int count = 0;count < n; count++) {
                y = x / 10;
                if (x % 3 == 0){
                    sb.append(" ")
                        .append(x);
                } else {
                    y = x;
                    while(y != 0) {
                        if (y % 10 == 3) {
                            sb.append(" ")
                                .append(x);
                            break;
                        }
                        y /= 10;
                    }
                }
                x++;
            }
            System.out.println(sb);
        } for (int count = 0;count < n; count++) {
                y = x / 10;
                if (x % 3 == 0){
                    sb.append(" ")
                        .append(x);
                } else {
                    y = x;
                    while(y != 0) {
                        if (y % 10 == 3) {
                            sb.append(" ")
                                .append(x);
                            break;
                        }
                        y /= 10;
                    }
                }
                x++;
            } int count = 0; int count = 0; count 0 count < n count n count++ count++ count {
                y = x / 10;
                if (x % 3 == 0){
                    sb.append(" ")
                        .append(x);
                } else {
                    y = x;
                    while(y != 0) {
                        if (y % 10 == 3) {
                            sb.append(" ")
                                .append(x);
                            break;
                        }
                        y /= 10;
                    }
                }
                x++;
            } {
                y = x / 10;
                if (x % 3 == 0){
                    sb.append(" ")
                        .append(x);
                } else {
                    y = x;
                    while(y != 0) {
                        if (y % 10 == 3) {
                            sb.append(" ")
                                .append(x);
                            break;
                        }
                        y /= 10;
                    }
                }
                x++;
            } y = x / 10 y x / 10 x 10 if (x % 3 == 0){
                    sb.append(" ")
                        .append(x);
                } else {
                    y = x;
                    while(y != 0) {
                        if (y % 10 == 3) {
                            sb.append(" ")
                                .append(x);
                            break;
                        }
                        y /= 10;
                    }
                } x % 3 == 0 x % 3 x 3 0 {
                    sb.append(" ")
                        .append(x);
                } sb.append(" ")
                        .append(x) sb.append(" ")
                        .append sb.append(" ") sb.append sb " " x {
                    y = x;
                    while(y != 0) {
                        if (y % 10 == 3) {
                            sb.append(" ")
                                .append(x);
                            break;
                        }
                        y /= 10;
                    }
                } y = x y x while(y != 0) {
                        if (y % 10 == 3) {
                            sb.append(" ")
                                .append(x);
                            break;
                        }
                        y /= 10;
                    } y != 0 y 0 {
                        if (y % 10 == 3) {
                            sb.append(" ")
                                .append(x);
                            break;
                        }
                        y /= 10;
                    } if (y % 10 == 3) {
                            sb.append(" ")
                                .append(x);
                            break;
                        } y % 10 == 3 y % 10 y 10 3 {
                            sb.append(" ")
                                .append(x);
                            break;
                        } sb.append(" ")
                                .append(x) sb.append(" ")
                                .append sb.append(" ") sb.append sb " " x break; y /= 10 y 10 x++ x System.out.println(sb) System.out.println System.out System System.out sb String args[] args
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        int n = scan.nextInt();
        int x = 1;
        int y = 0;
        if (n >= 3 && n <= 10000) {
            for (int count = 0;count < n; count++) {
                y = x / 10;
                if (x % 3 == 0){
                    sb.append(" ")
                        .append(x);
                } else {
                    y = x;
                    while(y != 0) {
                        if (y % 10 == 3) {
                            sb.append(" ")
                                .append(x);
                            break;
                        }
                        y /= 10;
                    }
                }
                x++;
            }
            System.out.println(sb);
        }
    }
}