using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace yukicoder { class yc { static void Main() { long a, b; string[] str = Console.ReadLine().Split(' '); a = long.Parse(str[0]); b = long.Parse(str[1]); while (a <= b) { if (a % 3 == 0) Console.WriteLine(a); else if (a.ToString().IndexOf('3') != -1) Console.WriteLine(a); a++; } } } }