import java.io.*;
import java.math.*;
import java.util.*;


 public class Main {
	private InputStream is;
	private PrintWriter out;
	int time = 0, dp[][], DP[][], start[], parent[], end[], val[], black[], MOD = (int)(1e9+7), arr[], arr1[];
	int MAX = 10000000, N, K, p;
	ArrayList<Integer>[] amp, amp1;
	boolean b[], b1[];
	Pair prr[];
	char ch[][];
	HashSet<Integer> hs = new HashSet<>();

	public static void main(String[] args) throws Exception {
		new Thread(null, new Runnable() {
		public void run() {
			try {

		//new Main().soln();
		} catch (Exception e) {
				System.out.println(e);
			}
		}
	}, "1", 1 << 26).start();
		new Main().soln();
	}
	void solve() {
		long n = nl(), s = nl();
		long low = 1, high = n+1;
		long ans = high;
		while(low<=high){
			long mid = (high+low)/2;
			if((mid - getSum(mid))>=s){
				high = mid-1;
				ans = mid;
			}
			else{
				low = mid+1;
			}
		}
		System.out.println(Math.max(0, n-ans+1));
	}
	int getSum(long s){
		String str = Long.toString(s);
		int ans = 0;
		for(char ch : str.toCharArray()) ans += (ch-'0');
		return ans;
	}
	int recur(int x){
		//System.out.println(x);
		int ans = 0;
		b[x] = true;
		for(int i : amp[x]){
			if(!b[i]){
				b[i] = true;
				ans = Math.max(recur(i), ans);
				b[i] = false;
			}
		}
		return 1+ans;
	}
	int max = 0;
	int getParent(int x){
		//System.out.println(x+" "+parent[x]);
		if(parent[x]!=x){
			parent[x] = getParent(parent[x]);
		}
		return parent[x];
	}
	int bfs(int x){
		b[x] = true;
		Queue<Integer> q =  new LinkedList<>();
		q.add(x);
		while(!q.isEmpty()){
			int y = q.poll();
			for(int i : amp[y]){
				if(!b[i]){
					b[i] = true;
					val[i] = val[y]+1;
					max = Math.max(val[i], max);
					q.add(i);
				}
			}
		}
		return max;
	}
	class Pair implements Comparable<Pair>{
		int u, v, r;
		Pair(int u, int v){
			this.u = u;
			this.v = v;
		}public int hashCode() {
			return Objects.hash();
		}
		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return ((u == other.u && v == other.v));// || (v == other.u && u ==... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?