import java.util.Scanner; import java.util.ArrayList; import java.lang.String; import java.lang.Integer; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); Integer a = sc.nextInt(); Integer b = sc.nextInt(); for (int i = a; i <= b; i++) { boolean flag = false; int sum = 0; String[] aStr = a.toString().split(""); for (int j = 0; j < aStr.length; j++) { int aInt = Integer.parseInt(aStr[j]); if (aInt == 3){ flag = true; } sum += aInt; } if (!flag) { if (sum%3 == 0){ flag = true; } } if (flag){ System.out.println(i); } a++; } } }