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 <= 100

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

**Example:
Input:**

2

13 2

10 5

4

1

**Explanation:**

```
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.

cs_abhi | 62 |

kya_bolti_public | 56 |

Shubhankar Sharma | 44 |

vermaankush14291 | 42 |

coderquill | 40 |

PiyushPandey4 | 856 |

john_wick | 757 |

ASWATHAMA | 565 |

akhyasharma01 | 547 |

UsfShilpa | 536 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.