import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import static java.lang.System.in; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String[] inputs = reader.readLine().split(" "); long A = Long.parseLong(inputs[0]); long B = Long.parseLong(inputs[1]); for (long i = A; i <= B; i++) { if (i % 3 == 0 || containsThree(i)) { System.out.println(i); } } } private static boolean containsThree(long n) { String ns = String.valueOf(n); for (int i = 0; i < ns.length(); i++) { if (ns.charAt(i) == '3') { return true; } } return false; } }