import java.util.Scanner; public class test2 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = 30; int m = 40; for(;n < m; n++) { if(n % 3 ==0) { System.out.println(n); continue; } else if(n % 10 == 3) { System.out.println(n); continue; } // なんだかなぁ int tmp = n; while(tmp > 10) { tmp = tmp /10; } if(tmp % 10 == 3) { System.out.println(n); } } } }