#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e5 + 5;
long long n, s;
long long l[22][22 * 9][2];
int sl, ss;
int cs[22];
long long cal(int i, int sum, bool ok) {
  if (i > sl) return l[i][sum][ok] = (sum == ss);
  if (l[i][sum][ok] != -1) return l[i][sum][ok];
  long long ans = 0;
  for (int j = 0; j <= 9; ++j)
    if (ok || j <= cs[i]) ans += cal(i + 1, sum + j, ok | (j < cs[i]));
  return l[i][sum][ok] = ans;
}
long long cal2(long long x, int sum) {
  sl = 0;
  while (x > 0) cs[++sl] = x % 10, x /= 10;
  for (int i = 1; i <= sl / 2; ++i) swap(cs[i], cs[sl - i + 1]);
  ss = sum;
  memset(l, 255, sizeof(l));
  return cal(1, 0, 0);
}
int main() {
  cin >> n >> s;
  long long ans = 0;
  for (int i = 1; i <= 9 * 19; ++i)
    if (s + i <= n) {
      ans += cal2(n, i) - cal2(s + i - 1, i);
    }
  cout << ans << endl;
}
