Farmer John wants to label his N (1 <= N <= 1,000,000) cows, but
cows don't like having the digit L (0 <= L <= 9) written on them,
so he avoids that.

If the cows are labeled with the smallest set of N positive integers
that don't have the digit L, what is the largest number that Farmer
John has to write on any cow?

输入格式

Line 1: Two space-separated integers: N and L.

输出格式

Line 1: A single integer that is the largest number that Farmer John has to write on any cow.

样例输入

10 1

样例输出

22


#include<stdio.h>
int n,l;
int main(){
	int i,cnt,num,s,flag;
	while(scanf("%d %d",&n,&l)!=EOF){
		cnt=0;
		for(i=1;;i++){
			num=i;
			flag=1;
			while(num>0){
				s=num%10;
				if(s==l){
					flag=0;
					break;
				}
				num=num/10;
			}
			if(flag){
				cnt++;
				if(cnt==n)
				break;
			}
			else
			continue;
		}
		printf("%d\n",i);
	}
	return 0;
}