import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] input = br.readLine().split(" "); int a = Integer.parseInt(input[0]); int b = Integer.parseInt(input[1]); for(int i = a; i <= b; i++){ if(i%3 == 0 || String.valueOf(i).contains("3")){ System.out.println(i); } } } }