using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace No207 { public class Program { public static void Main(string[] args) { var inputs = Console.ReadLine().Split().Select(long.Parse).ToArray(); for (long i = inputs[0]; i <= inputs[1]; i++) { if (i%3 == 0 || i.ToString().IndexOf("3")>=0) { Console.WriteLine(i); } } } } }