using System; class Program { static void Main(string[] args) { //入力 string s = Console.ReadLine(); string[] t = s.Split(' '); //数字の割り当て int a = int.Parse(t[0]); int b = int.Parse(t[1]); //出力 for (int i = a; i <= b; i++) { if (i % 3 == 0 || i / 1000000000 == 3 || i / 100000000 == 3 || i / 10000000 == 3 || i / 1000000 == 3 || i / 100000 == 3 || i / 10000 == 3 || i / 1000 == 3 || i / 100 == 3 || i / 10 == 3 || i % 10 == 3) { Console.WriteLine(i); } } } }