package yukiCoder; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class No00207 { public static void main(String[] args) { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); String[] input = new String[2]; try { input = bufferedReader.readLine().split(" "); int start = Integer.parseInt(input[0]); int end = Integer.parseInt(input[1]); calculation(start,end); } catch (IOException e) { e.printStackTrace(); } } public static void calculation(int start, int end) { if (start > end) { return; } for (; start <= end ; start++) { if (isMultipleOfThree(start) || isDigitIncludingThree(start)) { System.out.println(start); } } } public static Boolean isMultipleOfThree(int input) { int fullDigitAns = 0; String check = String.valueOf(input); for (int i = 0 ; i < check.length() ; i++) { int digit = Integer.parseInt(String.valueOf(check.charAt(i))); fullDigitAns += digit; } return fullDigitAns%3 == 0 ? true : false; } public static Boolean isDigitIncludingThree(int input) { String check = String.valueOf(input); for (int i = 0 ; i < check.length() ; i++) { int digit = Integer.parseInt(String.valueOf(check.charAt(i))); if (digit == 3) return true; } return false; } }