import java.util.Scanner;
public class Main {
public static int FuyiNum(int[] arr) {
int ans=0;
for(int i=0;i<arr.length;i++) {
if(arr[i]==-1) ans++;
}
return ans;
}
public static boolean IsExist(int a,int k) {
if(a % k ==0) return true;
while(a>10) {
a = a % 10;
}
if(a==k) return true;
return false;
}
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int k = s.nextInt();
int[] arr = new int[n];
for(int i=1;i<=n;i++) {
arr[i-1]=i;
}
int count =0;
while(FuyiNum(arr)!=arr.length-1) {
for(int i=0;i<n;i++) {
if(arr[i]!=-1) {
count++;
if(IsExist(count,k)) arr[i]=-1;
if(FuyiNum(arr)==arr.length-1) break;
}
}
}
for(int i=0;i<n;i++) {
if(arr[i]!=-1) System.out.print(arr[i]);
}
}
}