using System; public class Test { public static int GetDigit (long value) { int digit = 0; while (value > 0) { value /= 10; digit++; } return digit; } public static void Main(string[] args) { string[] nums = Console.ReadLine().Split(' '); long min = long.Parse(nums[0]); // min >= 1 long max = long.Parse(nums[1]); for (long i = min; i <= max; i++) { if (i % 3 == 0|| i % 10 == 3 || (int)(i / System.Math.Pow(10,GetDigit(i)-1)) == 3) { Console.WriteLine(i); } } } }