import java.util.*; import java.math.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int A = sc.nextInt(); int B= sc.nextInt(); for(; A<=B; A++){ if(A%3==0){ System.out.println(A); continue; } int tmp = A; while(tmp!=0){ if(tmp%10==3){ System.out.println(A); break; } tmp/=10; } } } }