import java.util.*; import java.lang.*; import java.io.*; class Main { public static boolean hasThree(int n){ return (((n-3)%10 == 0) || 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);} } } }