Given a positive value N, we need to find the count of numbers smaller than and equal to N such that the difference between the number and sum of its digits is greater than or equal to given specific value k.

**Input:**

The first line of input contains an integer T denoting the number of test cases. Each test case contains two space separated integers N and k.

**Output:**

Print an integer which is the required value.

**Constraints:**

1<=T<=50

1<=N,k<=10^{9}

**Example:
Input:**

2

13 2

10 5

4

1

```
Input : N = 13, diff = 2
Output : 4
Then 10, 11, 12 and 13 satisfy the given
condition shown below,
10 – sumofdigit(10) = 9 >= 2
11 – sumofdigit(11) = 9 >= 2
12 – sumofdigit(12) = 9 >= 2
13 – sumofdigit(13) = 9 >= 2
Whereas no number from 1 to 9 satisfies
above equation so final result will be 4
```

Author: shashwat jain

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

GustavoMéndez | 191 |

VivSisMMM | 182 |

d_Coder00 | 177 |

ajayjadhav35 | 161 |

Astikeysingh | 154 |

Pulkit__Sharma__ | 694 |

Anirban166 | 652 |

abducodes | 562 |

Found_me | 542 |

Sathvik Avasarala | 514 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4559 |

Login to report an issue on this page.