#include int main(void){ long A, B, t; scanf("%d%d", &A, &B); do{ t = A; if(A % 3 == 0){ printf("%d\n", A); } else{ while(t != 0){ if(t % 10 == 3){ printf("%d\n", A); break; } t /= 10; } } A++; }while(A != B + 1); return 0; }