import java.util.Scanner; public class Exercises4{ public static void main (String[] args){ Scanner sc = new Scanner(System.in); int firstNum = sc.nextInt(); int secondNum = sc.nextInt(); for(int n = firstNum; n <= secondNum; n++){ if (n % 3 == 0 || isThreeExist(n)){ System.out.println(n); } } } private static boolean isThreeExist(int a){ char[] array = String.valueOf(a).toCharArray(); for(char ca: array){ if(ca == '3'){ return true; } } return false; } }