#C8273. Find the Special Number

    ID: 52237 Type: Default 1000ms 256MiB

Find the Special Number

Find the Special Number

Given an integer \( x \), your task is to determine the smallest integer \( y \) such that \( y > x \) and the following two conditions hold:

  • \( y \) is divisible by 3 but not divisible by 9, i.e., \( 3 \mid y \) and \( 9 \nmid y \).
  • The sum of the digits of \( y \) is divisible by 3 but not divisible by 9, i.e., if \( S(y) \) denotes the sum of digits, then \( 3 \mid S(y) \) and \( 9 \nmid S(y) \).

Your program should read an integer from standard input and output the corresponding smallest valid \( y \) to standard output.

inputFormat

The input consists of a single line containing an integer \( x \) \( (1 \le x \le 10^9) \).

outputFormat

Output a single integer \( y \) which is the smallest number greater than \( x \) satisfying the conditions above.

## sample
10
12