#include<bits/stdc++.h>
#include<strstream>
using namespace std;
string szc(int a)
{
strstream b;
string c;
b<<a;
b>>c;
return c; 
}
int xysz(int x)
{
string c;
long long i,a=x,b[100001]={},d=0,e;
if(x<10) return 0;
while(a!=0)
{
e=a%10;
a=a/10;
d++;
b[d]=e;
}
for(i=d;i>=1;i--)
c=c+szc(b[i]);
for(i=0;i<=d-1;i++)
{
if(b[i]==b[i-1]||b[i]==b[i+1]) return 0;
if(!c.find(szc(i),0)&&!c.find(szc(i++),0)&&!c.find(szc(i--),0)) return 0;
}
return 1;
}
int main()
{
long long a,b,i,k=0;
cin>>a>>b;
for(i=a;i<=b;i++)
if(xysz(i)==1) {cout<<i<<endl;k++;}
cout<<k;
}