import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); ArrayList thList = new ArrayList<>(); int A = sc.nextInt(); int B = sc.nextInt(); int cnt = 0; for(int i = A; i <= B; i++) { if(i % 3 == 0) { thList.add(i); cnt++; } else if(String.valueOf(i).contains("3")) { thList.add(i); cnt++; } } for(int i = 0; i < cnt; i++) { System.out.println(thList.get(i)); } } }