import java.util.*; import java.util.stream.*; public class Main{ public static void main(String... args){ Scanner sc=new Scanner(System.in); long a=sc.nextLong(); long b=sc.nextLong(); for(long i=a;i<=b;i++){ if(i%3==0||isAttached3(i)){ System.out.println(i); } } } public static boolean isAttached3(long x){ String s=Long.toString(x); for(char c:s.toCharArray()){ if(c=='3')return true; } return false; } }