#B3970. Digit Modulo Transformation

    ID: 11627 Type: Default 1000ms 256MiB

Digit Modulo Transformation

Digit Modulo Transformation

On Little S's birthday, Little Q prepared a four-digit number \(x\) as a gift. However, Little S doesn't like digits that are \(\ge k\). To solve this, Little Q transforms each digit of \(x\) by replacing it with the remainder when that digit is divided by \(k\), i.e., for each digit \(d\), it is replaced by \(d \bmod k\).

Your task is to compute the final form of \(x\) after this transformation.

Note: Even if a digit is less than \(k\), you must still perform the modulo operation (which will yield the digit itself).

The modulo operation is defined as follows: \[ d \bmod k = d - k \left\lfloor \frac{d}{k} \right\rfloor \]

inputFormat

The input consists of a single line containing two integers separated by a space:

  • x: A four-digit integer.
  • k: An integer used for the modulo operation.

You may assume that \(1 \leq k \leq 9\) and \(x\) is a valid four-digit number.

outputFormat

Output the transformed number after replacing every digit \(d\) of \(x\) with \(d \bmod k\). The resulting number should be printed as an integer (leading zeros, if any, may be omitted).

sample

1234 5
1234