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