#P5834. MooBuzz

    ID: 19062 Type: Default 1000ms 256MiB

MooBuzz

MooBuzz

Farmer John's cows have recently become enamored with a twist on the classic FizzBuzz game. In the standard game, players count upward beginning from 1. However, if a number is a multiple of 3, the player says Fizz; if it is a multiple of 5, the player says Buzz; and if it is a multiple of both 3 and 5 (i.e. a multiple of (15)), the player says FizzBuzz. In the cows' version, to cope with a limited vocabulary, they replace any occurrence of Fizz, Buzz, or FizzBuzz with Moo.

For example, the beginning of the standard game is:

1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16

In the cow version, it becomes:

1, 2, Moo, 4, Moo, Moo, 7, 8, Moo, Moo, 11, Moo, 13, 14, Moo, 16

Only the numbers that are not replaced by "Moo" are actually spoken as integers. These numbers (in order) are: 1, 2, 4, 7, 8, 11, 13, 14, 16, ...

Given an integer (N), your task is to find the (N)th number that is spoken (i.e. not replaced by Moo).

inputFormat

The input consists of a single integer (N) ( (1 \leq N \leq 10^{9}) ) on one line, representing the index (1-indexed) of the spoken number in the Moo version of the game.

outputFormat

Output a single integer, which is the (N)th number that is actually spoken (i.e. numbers that are not replaced with "Moo").

sample

1
1