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