Back
Close
  • 107

Statement

 Goal

Given an input number, output the largest number possible that follows these rules:
1. The output number must be divisible by D
2. The output number must be created by removing between 0 and 2 digits from the input number (you cannot change the order of the digits)
3. If it is not possible to make a number following the above rules, output 0

For example:
314159
3

Should output
31419
Input
Line 1: number
Line 2: D
Output
Line 1: The number you found.
Constraints
1000 ≤ number ≤ 1000000000
2 ≤ D ≤ 10
Example
Input
3141
3
Output
3141

A higher resolution is required to access the IDE