import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Main { public static void main(String... args) throws IOException { try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) { int[] arr = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); for (int i = arr[0]; i <= arr[1]; i++) { if (i % 3 == 0 || has3(i)) { System.out.println(i); } } } } static boolean has3(int num) { for (int i = num; 0 < i; i /= 10) { if (i % 10 == 3) { return true; } } return false; } }