Description
Solutions
Counting Game

The counting game is a widely popular casual game. Every participant in the game must count numbers in sequence. However, if the next number to be called is a multiple of 7, or if the next number contains the digit 7, then that number must be skipped, otherwise, you lose the game.

Rose and Zack play this game and find it too easy, so they decide to modify some rules: for any number containing the digit 7, all its multiples cannot be called either!

For example, if Rose calls out 6, since 7 cannot be called, Zack must call 8 next. If Rose calls out 33, since 34 is 17 times 2 and 35 is 7 times 5, Zack's next possible call is 36. If Rose calls out 69, because numbers 70 to 79 all contain the digit 7, Zack's next call must be 80.

Input Format

Input a line which contains a positive integer x, indicating the number called by Rose this time.

Output Format

Output a line which contains an integer. If the number called by Rose this time is invalid (cannot be called), output -1. Otherwise, output the number that Zack should call next.

Note: All example explanations below are EDUCATED GUESSES :)

Example 1:

Input:  x = 6
Output: 8
Explanation:
Since 7 cannot be called, Zack must call 8 next.

Example 2:

Input:  x = 33
Output: 36
Explanation:
Since 34 is 17 times 2 and 35 is 7 times 5, Zack's next possible call is 36.

Example 3:

Input:  x = 300
Output: -1
Explanation:
Since 300 is a multiple of 30 which contains the digit 7, it cannot be called. Therefore, the output is -1.
Constraints:
    🐠
Thumbnail 0
Testcase

Result
Case 1

input:

output: