import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int start = sc.nextInt(); int end = sc.nextInt(); sc.close(); for(int i=start;i<=end;i++){ String str = String.valueOf(i); if(i%3==0||str.contains("3")){ System.out.println(i); } } }// mainmethod } // class