#include using namespace std; using ll = long long; // -------------------------------------------------------- template bool chmax(T& a, const T b) { if (a < b) { a = b; return 1; } return 0; } template bool chmin(T& a, const T b) { if (b < a) { a = b; return 1; } return 0; } #define FOR(i,l,r) for (int i = (l); i < (r); ++i) #define REP(i,n) FOR(i,0,n) #define ALL(c) (c).begin(), (c).end() #define RALL(c) (c).rbegin(), (c).rend() #define SORT(c) sort(ALL(c)) #define RSORT(c) sort(RALL(c)) #define MIN(c) *min_element(ALL(c)) #define MAX(c) *max_element(ALL(c)) #define SUM(c) accumulate(ALL(c), 0) #define SUMLL(c) accumulate(ALL(c), 0LL) #define SZ(c) ((int)(c).size()) #define debug(x) cerr << #x << " = " << (x) << '\n'; using P = pair; using VP = vector

; using VVP = vector; using VS = vector; using VI = vector; using VVI = vector; using VLL = vector; using VVLL = vector; using VB = vector; using VVB = vector; using VD = vector; using VVD = vector; static const double EPS = 1e-10; static const double PI = acos(-1.0); static const ll MOD = 1000000007; // static const ll MOD = 998244353; static const int INF = 1 << 30; // static const ll INF = 1LL << 62; // -------------------------------------------------------- // #include // using namespace atcoder; int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(10); ll A, B; cin >> A >> B; FOR(x, A, B + 1) { string y = to_string(x); int digit_sum = 0; bool exist_three = false; for (char s : y) { if (s == '3') exist_three = true; digit_sum += (s - '0'); } if (digit_sum % 3 == 0 || exist_three) { cout << x << '\n'; } } return 0; }