#include<bits/stdc++.h> using namespace std; int a,b,ans; bool v[20]; void ALL(int x,int now,int dep){ if(dep==x){ if(now>=a&&now<=b){ ans++; cout<<now<<"\n"; } return; } if(dep==0){ for(int i = 1;i<x;i++){ if(v[i]==0){ v[i]=1; ALL(x,now*10+i,dep+1); v[i]=0; } } }else{ for(int i = 0;i<x;i++){ if(v[i]==0){ v[i]=1; ALL(x,now*10+i,dep+1); v[i]=0; } } } } int log(int a,int s){ if(s==0)return 1145; int cnt = 0; while(s){ cnt++; s/=a; } return cnt; } int main(){ cin>>a>>b; int len1 = log(10,a),len2 = log(10,b); if(a>b)swap(a,b); for(int i = len1;i<=len2;i++){ ALL(i,0,0); } cout<<ans; return 0; }