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