a,b,p,q;main(t){scanf("%d%d",&a,&b);for(p=a/10;(p/=10)&&p%10-3;);for(q=b/10;(q/=10)&&q%10-3;);for(t=b%100>a%100;a<=b;a++)!(t|a%100>b%100?p:q)&&a%10-3&&a/10%10-3&&a%3&&printf("%d\n",a);}