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