import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long A = sc.nextLong(); long B = sc.nextLong(); while(A<=B){ if(A%3==0){ System.out.println(A); }else{ String s = String.valueOf(A); if(s.contains("3")){ System.out.println(A); } } A++; } } }