package com.thinker.bishi.toutiao;


import java.util.Scanner;

public class Main3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int max =  sc.nextInt();
        int k = sc.nextInt();
        int i=1,j=0,count = 0,result = 0,curr=i;
        int tmp = 0;
        while (count<k){
            while (i*10<(j*10+i-tmp) && i*10 <= max){
                result = i*10;count++;i++;
                if(count>=k) break;
            }
            while (i*10>(j*10+i) && (j*10+i-1)<=max){
                result = j*10+i-1;j++;count++;
                if(count>=k) break;
            }
            if(i*10>max && (j*10-curr) > max){curr ++;}
            if(i*10>max || (j*10+curr)>max){j=0;curr = i;}
        }
        System.out.println(result);
    }
}
