#include <bits/stdc++.h>
using namespace std;
int d[20];
long long xi[20], dp[21][21];
int main() {
  long long n, s;
  int i, j, k;
  while (cin >> n >> s) {
    memset(dp, 0, sizeof(dp));
    long long t = 0, x;
    int flag = 1;
    int sum = 0;
    while (n) {
      xi[sum] = t;
      d[sum++] = n % 10;
      n = n / 10;
      t = t * 10 + 9;
    }
    sum--;
    if (xi[sum]) {
      x = s / xi[sum];
      s %= xi[sum];
    } else
      x = 10;
    for (i = x; i <= d[sum]; i++) dp[sum][i] = 1;
    if (x > 9) flag = 0;
    t = x;
    for (i = sum - 1; i >= 0; i--) {
      if (xi[i])
        x = s / xi[i];
      else {
        if (s == 0)
          x = 0;
        else
          x = 10;
      }
      for (j = 0; j <= 9; j++)
        for (k = 0; k <= 9; k++) {
          dp[i][j] += dp[i + 1][k];
          if (k == t && j < x && flag) dp[i][j]--;
          if (k == d[i + 1] && j > d[i]) dp[i][j]--;
          if (dp[i][j] < 0) dp[i][j] = 0;
        }
      t = x;
      if (xi[i]) {
        s %= xi[i];
      }
      if (x > 9) flag = 0;
    }
    long long ans = 0;
    for (i = 0; i <= 9; i++) ans += dp[0][i];
    cout << ans << endl;
  }
}
