codeparrot/codecomplex huggingface dataset:
// Problem: 817_C. Really Big Numbers
// Time complexity: logn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class C {

	public static void main(String[] args) throws InterruptedException{
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		long n = scan.nextLong(), s = scan.nextLong();
		long lo = 1, hi = n+1;
		for(int bs = 0; bs < 100; bs++) {
			long mid = (lo+hi)>>1;
			long mid2 = mid;
			long c = 0;
			while(mid > 0) {
				c += mid%10;
				mid /= 10;
			}
			if(mid2-c < s) lo = mid2;
			else hi = mid2;
		}
		out.println(n-lo);
		out.close();
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			try	{
				br = new BufferedReader(new InputStreamReader(System.in));
				st = new StringTokenizer(br.readLine());
			} catch (Exception e){e.printStackTrace();}
		}

		public String next() {
			if (st.hasMoreTokens())	return st.nextToken();
			try {st = new StringTokenizer(br.readLine());}
			catch (Exception e) {e.printStackTrace();}
			return st.nextToken();
		}

		public int nextInt() {return Integer.parseInt(next());}

		public long nextLong() {return Long.parseLong(next());}

		public double nextDouble() {return Double.parseDouble(next());}

		public String nextLine() {
			String line = "";
			if(st.hasMoreTokens()) line = st.nextToken();
			else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
			while(st.hasMoreTokens()) line += " "+st.nextToken();
			return line;
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for(int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n){
			long[] a = new long[n];
			for(int i = 0; i < n; i++) a[i] = nextLong();
			return a;
		}

		public double[] nextDoubleArray(int n){
			double[] a = new double[n];
			for(int i = 0; i < n; i++) a[i] = nextDouble();
			return a;
		}

		public char[][] nextGrid(int n, int m){
			char[][] grid = new char[n][m];
			for(int i = 0; i < n; i++) grid[i] = next().toCharArray();
			return grid;
		}
	}

}
// Problem: 817_C. Really Big Numbers
// Time complexity: logn
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 *
 * @author Fuad
 */
public class Codeforces {

    private static boolean greater(long mid, long s) {

        int sum = 0;
        long num = mid;

        while (num != 0) {
            sum += (num % 10);
            num /= 10;

        }

        return mid - sum >= s;
    }

    static class pair {

        int first;
        int second;

        pair(int f, int s) {
            first = f;
            second = s;
        }

        pair() {

        }

    }

    public static void main(String[] args) throws Exception {
        // TODO code application logic here
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        long n, s;

        String arr[] = br.readLine().split(" ");

        n = Long.parseLong(arr[0]);
        s = Long.parseLong(arr[1]);

        long l = 1;
        long h = n;

        while (l < h) {
            long mid = (l + h) / 2;
            if (greater(mid, s)) {
                h = mid;
            } else {
                l = mid + 1;
            }
        }

        System.out.println(greater(h, s) ? n - h + 1 : 0);

    }

}
// Problem: 817_C. Really Big Numbers
// Time complexity: logn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.StringTokenizer;


public class Solution {
	
	long sum(long n){
		long sm = 0;
		
		while(n!=0){
			sm+=(n%10);
			n/=10;
		}
		
		return sm;
		
	}
	
	void solve() throws IOException{
		
		long n = in.nextLong();
		long s = in.nextLong();
		
		long l = 0;
		long h = n+1;
		long ans = -1;
		
		while(l<h){
			 long mid = (l + h)/2;
			 
			 long sum = sum(mid);
			 
			 if(mid - sum >= s){
				 ans = mid;
				 h = mid;
			 }
			 else
				 l = mid+1;
			 
			// System.out.println(mid);
			 
			// ans = (mid+1);
			
		}
		
	//	System.out.println(ans);
		
		if(ans==-1)
			out.println("0");
		else
			out.println(n+1-ans);
		
		
				
			
		
		
		
		
		
		
	} // solve

	class FastScanner{
		BufferedReader br;
		StringTokenizer st;
	
		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer("");
		}
		
		public int nextInt() throws IOException{
			 if(st.hasMoreTokens())
				return Integer.parseInt(st.nextToken());
			else{
				st = new StringTokenizer(br.readLine());
				return nextInt();
			}			
		}
		
		public long nextLong() throws IOException{
			 if(st.hasMoreTokens())
				return Long.parseLong(st.nextToken());
			else{
				st = new StringTokenizer(br.readLine());
				return nextLong();
			}			
		}
		
		public String readLine() throws IOException{
			return br.readLine();
		}
	}
	
	FastScanner in = new FastScanner();
	static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); 
	
	
	public static void main(String args[])throws IOException{
		 new Solution().solve();
		 out.close();
	}

}
// Problem: 817_C. Really Big Numbers
// Time complexity: logn
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {

	static int[] UPPER = new int[64], LOWER = new int[64];
	static long[][][] memo;
	
	static long dp(int bit, int lims, int digs)
	{
		if(bit == -1)
			return digs == 0 ? 1 : 0;
		if(memo[lims][bit][digs] != -1)
			return memo[lims][bit][digs];
		long ret = 0;
		for(int d = 0, end = digs < 10 ? digs + 1 : 10; d < end; ++d)
			if(((lims & 1) == 1 || d >= LOWER[bit]) && ((lims & 2) == 2 || d <= UPPER[bit]))
				ret += dp(bit - 1, lims | (d > LOWER[bit] ? 1 : 0) | (d < UPPER[bit] ? 2 : 0), digs - d);
		return memo[lims][bit][digs] = ret;
	}
	
	static void create(int[] x, long n)
	{
		for(int i = 0; i < 64; ++i)
		{
			x[i] = (int) (n % 10);
			n /= 10;
		}
	}
	
	static void prepMemo(int sod)
	{
		memo = new long[4][64][sod + 1];
		for(long[][] x: memo)
			for(long[] y: x)
				Arrays.fill(y, -1);
	}

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		long n = sc.nextLong(), s = sc.nextLong();
		create(UPPER, n);
		long ans = 0;
		for(int sod = 1; sod <= 162; ++sod)
		{
			create(LOWER, s + sod);
			prepMemo(sod);
			ans += dp(63, 0, sod);
		}
		
		
		out.println(ans);
		out.close();
	}
	
	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public Scanner(String s) throws FileNotFoundException{	br = new BufferedReader(new FileReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException { return Double.parseDouble(next()); }

		public boolean ready() throws IOException {return br.ready();} 
	}
}
// Problem: 817_C. Really Big Numbers
// Time complexity: logn
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();
            long s = in.nextLong();
            long ans = 0;
            long i = 0;
            for (i = s; i <= n; i++) {
                long t = i - sum(i);
                if (t >= s) {
                    if (i % 10 == 9) {
                        break;
                    }
                    ans++;
                }
            }
            if (n >= s) {
                out.println(ans - i + n + 1);
            } else {
                out.println(0);
            }
        }

        static long sum(long a) {
            long sum = 0;
            while (a != 0) {
                sum += (a % 10);
                a /= 10;
            }
            return sum;
        }

    }
}
// Problem: 817_C. Really Big Numbers
// Time complexity: logn
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class C {

	static StringTokenizer st;
	static BufferedReader br;
	static PrintWriter pw;
	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		long n = nextLong();
		long s = nextLong();
		long ans = 0;
		if (s+200 <= n)
			ans += n - (s+200) + 1;
		for (long i = s; i < s+200; i++) {
			if (i <= n && i-sumDigits(i) >= s) {
				ans++;
			}
		}
		System.out.println(ans);
		pw.close();
	}
	private static long sumDigits(long n) {
		long sum = 0;
		while (n > 0) {
			sum += n % 10;
			n /= 10;
		}
		return sum;
	}
	private static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	private static long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	private static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
	private static String next() throws IOException {
		while (st==null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}
}
// Problem: 817_C. Really Big Numbers
// Time complexity: logn
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
//        InputStream inputStream = new FileInputStream("dijkstra.in");
        OutputStream outputStream = System.out;
//        OutputStream outputStream = new FileOutputStream("dijkstra.out");
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Answer solver = new Answer();
        solver.solve(in, out);
        out.close();
    }
}

class Answer {
    private int sumd(long x) {
        int sum = 0;
        while (x != 0) {
            sum += x % 10;
            x /= 10;
        }
        return sum;
    }

    private long bin(long l, long r, long s) {
        if (l > r) {
            return -1;
        }
        long x = (l + r) >> 1;
        int sum = sumd(x);
        if (x - sum < s) {
            return bin(x + 1, r, s);
        }
        long t = bin(l, x - 1, s);
        if (t != -1) {
            return t;
        }
        return x;
    }

    public void solve(InputReader in, PrintWriter out) throws IOException {
        long n = in.nextLong();
        long s = in.nextLong();
        long t = bin(1, n, s);
        if (t == -1) {
            out.print("0");
        } else {
            long ans = n - t + 1;
            out.print(ans);
        }
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }
}
// Problem: 817_C. Really Big Numbers
// Time complexity: logn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.util.ArrayList;

public class C{
	
	static long s;
	public static void main(String[] args)throws IOException {
		Reader.init(System.in);
		long n=Reader.nextLong();
		s=Reader.nextLong();
		long lo=1,hi=n,mid;
		while(lo<hi){
			mid=(lo+hi)/2;
			if(diff(mid)>=s)
				hi=mid;
			else
				lo=mid+1;
		}
		if(diff(lo)>=s)
			System.out.println(n-lo+1);
		else
			System.out.println(0);
	}
	
	static long diff(long n){
		String s=String.valueOf(n);
		int sum=0;
		
		for(int i=0;i<s.length();i++){
			
			sum+=Integer.parseInt(s.valueOf(s.charAt(i)));
		}
		return (n-sum);
	}
		
		
}


		
/** Class for buffered reading int and double values */
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}
// Problem: 817_C. Really Big Numbers
// Time complexity: logn
import java.io.*;
import java.util.*;
public class TestClass {
    static PrintWriter out = new PrintWriter(System.out);
    public static void main(String args[] ) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    	String s[] = in.readLine().split(" ");
    	long n = Long.parseLong(s[0]);
    	long k = Long.parseLong(s[1]);
    	long x = bs(n,k);
    	out.println(n-x+1);
        out.close();
    }
    public static long bs(long n,long k)
    {
    	long l=0,h=n;
    	while(l<=h)
    	{
    		long mid = l + (h-l)/2;
    		long x = mid - sum(mid);
    		if(x>=k)
    		{
    			h = mid-1;
    		}
    		else
    		{
    			l = mid+1;
    		}
    	}
    	return l;
    }
    public static long sum(long x)
    {
    	long ans=0;
    	while(x>0)
    	{
    		ans += x%10;
    		x=x/10;
    	}
    	return ans;
    }
}
// Problem: 817_C. Really Big Numbers
// Time complexity: logn
import java.io.*;
import java.util.*;

public class C
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		long n = Long.parseLong(in.next());
		long s = Long.parseLong(in.next());
		if(!check(n, s)){
			System.out.println(0);
		}
		else
		{
			long min = 1;
			long max = n;
			while(min != max)
			{
				long mid = (min + max) / 2;
				if(check(mid, s))
				{
					max = mid;
				}
				else
				{
					min = mid + 1;
				}
			}
			//System.out.println("found: " + min);
			System.out.println((n - min + 1));
		}
	}
	public static boolean check(long x, long s)
	{
		if(x - sumd(x) < s)
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	public static long sumd(long x)
	{
		long sum = 0;
		while(x != 0)
		{
			sum += x % 10;
			x /= 10;
		}
		return sum;
	}
}
// Problem: 817_C. Really Big Numbers
// Time complexity: logn

import java.util.Scanner;


public class ReallyBigNumbers1 
{
    
    public static void main(String[] args) 
    {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long s = sc.nextLong();
        
        int r = 0 ;
        
        long l = 0L ;
        long u = n ;
        
        if(  (l-sumDigits(l)< s )  && (u-sumDigits(u)< s ) )
        {
            System.out.println(0);
            return ;
        }
        
        long specified = 0L ;
        while( true )
        {
            long m = (l + u) / 2L ;
            
            if( ( m - sumDigits(m) ) >= s && ( (m-1) - sumDigits(m-1) ) < s  )
            {
                specified = m ;
                break ;
            }
            
            if( l > u  )
                break ;
            
            else
            {
                if( ( m - sumDigits(m) ) >= s )
                    u = m-1 ;
                else
                    l = m+1 ;
            }
        }
        
        System.out.println( n-specified+1 );
        
        
    }
    
    public static int sumDigits(long n)
    {
        char [] a = (n+"").toCharArray();
        int sum = 0 ;
        for(int k = 0 ; k < a.length ; k++)
        {
            sum += Integer.parseInt(a[k]+"") ;
        }
        return sum ;
    }
    
}
// Problem: 817_C. Really Big Numbers
// Time complexity: logn
import java.io.*;
import java.util.*;


public class Main {

	class IO {
		BufferedReader reader;
		PrintWriter writer;
		StringTokenizer tokenizer;

		IO() {
			reader = new BufferedReader(new InputStreamReader(System.in));
			writer = new PrintWriter(new BufferedOutputStream(System.out));
			tokenizer = new StringTokenizer("");
		}

		IO(String file) throws FileNotFoundException {
			reader = new BufferedReader(new FileReader(file));
			writer = new PrintWriter(new BufferedOutputStream(System.out));
			tokenizer = new StringTokenizer("");
		}

		String next() throws IOException {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				String line = reader.readLine();
				if (line == null)
					return null;
				tokenizer = new StringTokenizer(line);
			}
			return tokenizer.nextToken();
		}

		public Integer nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public Double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public void write(Object obj) {
			writer.print(obj.toString());
		}

		public void writeSpace(Object obj) {
			writer.print(obj.toString() + " ");
		}

		public void writeLine(Object obj) {
			writer.println(obj.toString());
		}

		public void close() {
			writer.close();
		}
	}

	IO io;

	Main() {
		io = new IO();
	}

	Main(String file) throws FileNotFoundException {
		io = new IO(file);
	}

	void solve() throws IOException {
		long n = io.nextLong(), s = io.nextLong();
		long min = s;
		while (true) {
			min++;
			long sum = 0, tem = min;
			while (tem > 0) {
				sum += tem % 10;
				tem /= 10;
			}
			if (min - sum >= s) break;
		}
		io.write(Math.max(0, n - min + 1));
	}

	void close() {
		io.close();
	}

	public static void main(String args[]) throws IOException {
		// Main solver = new Main("input.txt");
		Main solver = new Main();
		solver.solve();
		solver.close();
	}
}
// Problem: 817_C. Really Big Numbers
// Time complexity: logn
import java.io.*;
import java.util.*;

public class Main {
	
	static InputReader in = new InputReader(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	
	
	public static void main(String[] args) {

		long n = in.nextLong();
		long s = in.nextLong();
		
		if(diff(n) < s) {
			System.out.println(0);
			out.close();
			return;
		}
		
		long lo = 1;
		long hi = n;
		while(lo < hi) {
			long mid = lo + (hi - lo) / 2;
			if(diff(mid) >= s)
				hi = mid;
			else
				lo = mid + 1;
		}
		System.out.println(n - lo + 1);
		
		out.close();
	}

	static long diff(long n) {
		char[] ca = (n + "").toCharArray();
		int sum = 0;
		for(char c : ca)
			sum += (c - '0');
		return n - sum;
	}
}


class InputReader {

	private final InputStream stream;
	private final byte[] buf = new byte[8192];
	private int curChar, snumChars;

	public InputReader(InputStream st) {
		this.stream = st;
	}

	public int read() {
		if (snumChars == -1)
			throw new InputMismatchException();
		if (curChar >= snumChars) {
			curChar = 0;
			try {
				snumChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (snumChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int nextInt() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public long nextLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public int[] nextIntArray(int n) {
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public String nextLine() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}

	public boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}

}
// Problem: 817_C. Really Big Numbers
// Time complexity: logn
import java.util.Scanner;

public class c {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		long s = scan.nextLong();
		scan.close();
		long start = s - s % 10;
		while (start <= n && !isBig(start, s)) {
			start += 10;
		}
		if (start > n) {
			System.out.println(0);
		} else {
			System.out.println(n - start + 1);
		}
	}

	private static boolean isBig(long a, long s) {
		char[] digits = ("" + a).toCharArray();
		int counter = 0;
		for (int i = 0; i < digits.length; i++) {
			counter += digits[i] - '0';
		}
		return a - counter >= s;
	}

}