// Arup Guha
// 12/23/2019
// Solution to 2019 December USACO Silver Problem: MooBuzz

import java.util.*;
import java.io.*;

public class moobuzz {

	public static void main(String[] args) throws Exception {
		
		// Read in the basic graph parameters.
		Scanner stdin = new Scanner(new File("moobuzz.in"));
		int n = stdin.nextInt();
		
		// Binary search the answer.	
		long low = 1, high = 2000000000, res=-1;

		while (true) {

			// We will guess mid.
			long mid = (low+high)/2;
			long guess = count(mid);
						
			// Must be higher.
			if (guess < n)
				low = mid+1;
				
			// Must be lower.
			else if (guess > n)
				high = mid-1;
				
			// We are pretty close, just count down to the right answer.
			else {
				res = mid;
				while (res%3 == 0 || res%5 == 0) res--;
				break;
			}
		}
		
		
		// Output to file.
		PrintWriter out = new PrintWriter(new FileWriter("moobuzz.out"));
		out.println(res);
		out.close();		
		stdin.close();
	}
	
	// Returns # of values spoken less than or equal to n.
	public static long count(long n) {
		return n - n/3 - n/5 + n/15;
	}
}		