Zhautykov Olympiad 2020 Azerbaijan National Team Selection Contest Revisited


That day finally came! With ultimate joy and happiness! Today, Mr.Mammadov has a wedding and, of course, his all friends, including Barish, Murad, Ziya, Rafael,Huseyn,Mahammad, and Mahmud, are drinking to his honor! But there is special condition: they want it to be a number-theoric cheering, so they count numbers starting from one, and when the number is divisible by 3 or 5, they drink and say “Salut!”, skipping that number. This is how they will count and drink:1, 2, Salut!, 4, Salut!, Salut!, 7, 8, Salut!,Salut!, 11, Salut!,... Mr.Mammadov saw his friends like this and remembered good old days, when he was the absolute god of competitive programming (now he is a legend). Recalling these days, he wanted to know what would be the N’th number his friends will say.For example, the 3’rd number is 4, and the 5’th number is 8 (as the sequence is like (1, 2, 4, 7 , 8, ...) ). Now he is busy with taking cliché wedding pictures, so you need to solve this problem for him.

Input format:

The number N (1 ≤ N1012 ) is given in the first and the last line.

Output format:

The N’th number said during the drinking phase.

Time limit 1 second
Memory limit 64 MiB
Input example #1
Output example #1
Input example #2
Output example #2
Source IZHO 2019-2020 Azerbaijan selection contest