import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int s = sc.nextInt(), x = sc.nextInt(), ans = 0, m = 1;
while(m <= s) {
int a = s / (m * 10), b = s / m % 10, c = s % m;
if(x != 0) {
if(b < x) ans += a * m;
if(b == x) ans += a * m + c + 1;
if(b > x) ans += (a + 1) * m;
} else {
if(b != 0) ans += a * m;
else ans += (a - 1) * m + c + 1;
}
m *= 10;
}
System.out.println(ans);
sc.close();
}
}