import java.util.*; import java.lang.*; import java.io.*; class Main { public static boolean hasThree(int n){ if(n==0){ return false; } else if((n-3)%10 == 0){ return true; } else { return hasThree(n/10); } } public static void main (String[] args) { Scanner sc = new Scanner(System.in); int a = Integer.parseInt(sc.next()); int b = Integer.parseInt(sc.next()); for(int i = a; i <= b; i++){ if (i%3 == 0 || hasThree(i)) { System.out.println(i);} } } }