import java.util.Scanner; class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int a = scan.nextInt(); int b = scan.nextInt(); for (int i = a; i <= b; i++) { String s = String.valueOf(i); if (i % 3 == 0 || s.indexOf("3") != -1) { System.out.println(i); } } scan.close(); } }