import static java.lang.System.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class worldNabeatsu { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String[] inputs = reader.readLine().split(" "); int startNum = Integer.parseInt(inputs[0]); int endNum = Integer.parseInt(inputs[1]); for(int i = startNum; i <= endNum; i++){ if(validThree(i)){ System.out.println(i); } } } static boolean validThree(int num){ boolean threeFlg = false; String str = String.valueOf(num); char[] charBox = str.toCharArray(); for(int i = 0; i < charBox.length; i++){ if(charBox[i] == '3'){ threeFlg = true; } } if(num % 3 == 0 || threeFlg ){ return true; } return false; } }