#include <bits/stdc++.h>
using namespace std;
unsigned long long int k, n, s;
long long mn, mx;
int tvngm(unsigned long long int s) {
  unsigned long long int v = s;
  int h = 0;
  while (v != 0) {
    h += v % 10;
    v = v - v % 10;
    v /= 10;
  }
  return h;
}
int main() {
  cin >> n >> s;
  mx = n;
  mn = 0;
  if (n == 1 && s == 1) {
    cout << 0 << endl;
    return 0;
  }
  while (1) {
    bool a = (mn + mx) / 2 >= tvngm((mn + mx) / 2) + s;
    bool b = (mn + mx) / 2 - 1 >= tvngm((mn + mx) / 2 - 1) + s;
    if (a && b) {
      mx = (mn + mx) / 2;
    } else if (!a && !b) {
      mn = (mn + mx) / 2;
    } else {
      cout << n - (mn + mx) / 2 + 1 << endl;
      return 0;
    }
    if (mx == mn + 1 && mx == n) {
      mn++;
      mx++;
    } else if (mx == mn + 1) {
      cout << 0 << endl;
      return 0;
    }
  }
  return 0;
}
