#include #define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++) const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; typedef vector vi; typedef vector vll; typedef pair pii; bool ok(ll a) { if (a % 3 == 0) return true; while (a) { int tmp = a%10; if (tmp == 3) return true; a /= 10; } return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll A, B; cin >> A >> B; for (ll i = A; i <= B; i++) { if (ok(i)) { cout << i << endl; } } return 0; }