import java.util.*;

public class Main {

	static void log(long i) {
		System.out.println(i);
	}
	static void log(String s) {
		System.out.println(s);
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		

		long total=0;
		
		for(int i=0; i<=n; i++) {
			if(i%15==0)
				continue;
			if(i%3==0)
				continue;
			if(i%5==0)
				continue;
			total+=i;
		}
		
		sc.close();
		log( total );
	}
} import java.util.*; util.* java public class Main {

	static void log(long i) {
		System.out.println(i);
	}
	static void log(String s) {
		System.out.println(s);
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		

		long total=0;
		
		for(int i=0; i<=n; i++) {
			if(i%15==0)
				continue;
			if(i%3==0)
				continue;
			if(i%5==0)
				continue;
			total+=i;
		}
		
		sc.close();
		log( total );
	}
} Main static void log(long i) {
		System.out.println(i);
	} log {
		System.out.println(i);
	} System.out.println(i) System.out.println System.out System System.out i long i i static void log(String s) {
		System.out.println(s);
	} log {
		System.out.println(s);
	} System.out.println(s) System.out.println System.out System System.out s String s s public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		

		long total=0;
		
		for(int i=0; i<=n; i++) {
			if(i%15==0)
				continue;
			if(i%3==0)
				continue;
			if(i%5==0)
				continue;
			total+=i;
		}
		
		sc.close();
		log( total );
	} main {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		

		long total=0;
		
		for(int i=0; i<=n; i++) {
			if(i%15==0)
				continue;
			if(i%3==0)
				continue;
			if(i%5==0)
				continue;
			total+=i;
		}
		
		sc.close();
		log( total );
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long total=0; total 0 for(int i=0; i<=n; i++) {
			if(i%15==0)
				continue;
			if(i%3==0)
				continue;
			if(i%5==0)
				continue;
			total+=i;
		} int i=0; int i=0; i 0 i<=n i n i++ i++ i {
			if(i%15==0)
				continue;
			if(i%3==0)
				continue;
			if(i%5==0)
				continue;
			total+=i;
		} {
			if(i%15==0)
				continue;
			if(i%3==0)
				continue;
			if(i%5==0)
				continue;
			total+=i;
		} if(i%15==0)
				continue; i%15==0 i%15 i 15 0 continue; if(i%3==0)
				continue; i%3==0 i%3 i 3 0 continue; if(i%5==0)
				continue; i%5==0 i%5 i 5 0 continue; total+=i total i sc.close() sc.close sc log( total ) log total String args[] args public class Main {

	static void log(long i) {
		System.out.println(i);
	}
	static void log(String s) {
		System.out.println(s);
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		

		long total=0;
		
		for(int i=0; i<=n; i++) {
			if(i%15==0)
				continue;
			if(i%3==0)
				continue;
			if(i%5==0)
				continue;
			total+=i;
		}
		
		sc.close();
		log( total );
	}
} public class Main {

	static void log(long i) {
		System.out.println(i);
	}
	static void log(String s) {
		System.out.println(s);
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		

		long total=0;
		
		for(int i=0; i<=n; i++) {
			if(i%15==0)
				continue;
			if(i%3==0)
				continue;
			if(i%5==0)
				continue;
			total+=i;
		}
		
		sc.close();
		log( total );
	}
} Main
import java.util.*;

public class Main {

	static void log(long i) {
		System.out.println(i);
	}
	static void log(String s) {
		System.out.println(s);
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		

		long total=0;
		
		for(int i=0; i<=n; i++) {
			if(i%15==0)
				continue;
			if(i%3==0)
				continue;
			if(i%5==0)
				continue;
			total+=i;
		}
		
		sc.close();
		log( total );
	}
}
