import static java.lang.System.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class worldNabeatsu_2 { static final int FIRST_MIN = 1; static final int SECOND_MIN = 1; static final int DIFF_MIN = 0; static final int FIRST_MAX = 2000000000; static final int SECOND_MAX = 2000000000; static final int DIFF_MAX = 100; public static void main(String[] args) { InputStreamReader re = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); ArrayList answerList = new ArrayList(); try{ String[] inputs = reader.readLine().split(" "); int firstNum = Integer.parseInt(inputs[0]); int secondNum = Integer.parseInt(inputs[1]); int diff = secondNum - firstNum; if(numJudge(firstNum, FIRST_MIN, FIRST_MAX) &&numJudge(secondNum, SECOND_MIN, SECOND_MAX) &&numJudge(diff, DIFF_MIN, DIFF_MAX)){ for(int i = firstNum; i <= secondNum; i++){ if(threeJudge(i)){ answerList.add(i); }else if(i % 3 == 0){ answerList.add(i); } } for(int display : answerList){ System.out.println(display); } }else{ System.out.println("入力された数値が有効な値ではありません。"); } }catch(NumberFormatException ne){ System.out.println("数字を入力してください"); }catch(IOException ie){ System.out.println("読み込み時にエラーが発生しました。"); }finally{ try{ reader.close(); re.close(); }catch(IOException ie){ System.out.println("InputStreamReaderかBufferedReaderのクローズに失敗しました。"); } } } static boolean numJudge(int input, int min, int max){ boolean result = false; if(input >= min && input <= max){ result = true; } return result; } static boolean threeJudge(int targetNum){ boolean result = false; String str = String.valueOf(targetNum); if(str.contains("3")){ result = true; } return result; } }