#include using namespace std; int main(){ cin.tie(0),ios::sync_with_stdio(false); int a,b; cin>>a>>b; string s; bool three; for(;a<=b;++a){ three=false; s=to_string(a); for(auto&i:s)if(i=='3')three=true; if(three||a%3==0)cout<