import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int A = scanner.nextInt(); int B = scanner.nextInt(); System.out.println(new Solver().solve(A, B)); } } class Solver { public String solve(int a, int b) { StringBuilder sb = new StringBuilder(); for (int i = a; i <= b; i++) { if (i % 3 == 0 || String.valueOf(i).contains("3")) { sb.append(i); sb.append("\n"); } } return sb.toString(); } }