import java.util.Scanner; public class Main{ private static Scanner sc=new Scanner(System.in); public static void main(String args[])throws Exception{ int a=sc.nextInt(),b=sc.nextInt(); for(int i=a;i<=b;i++){ if(i%3==0 || in3(i)){ System.out.println(i); } } } private static boolean in3(int i){ String s=String.valueOf(i); if(s.indexOf("3")==-1)return false; else return true; } }