import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y=0;
		for(int i=1;i<=x;i++){
			if(i%3!=0&&i%5!=0){
				y+=i;
			}
				
		}
			System.out.print(y);

		

	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y=0;
		for(int i=1;i<=x;i++){
			if(i%3!=0&&i%5!=0){
				y+=i;
			}
				
		}
			System.out.print(y);

		

	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y=0;
		for(int i=1;i<=x;i++){
			if(i%3!=0&&i%5!=0){
				y+=i;
			}
				
		}
			System.out.print(y);

		

	} main {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y=0;
		for(int i=1;i<=x;i++){
			if(i%3!=0&&i%5!=0){
				y+=i;
			}
				
		}
			System.out.print(y);

		

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long x = sc.nextLong(); x sc.nextLong() sc.nextLong sc long y=0; y 0 for(int i=1;i<=x;i++){
			if(i%3!=0&&i%5!=0){
				y+=i;
			}
				
		} int i=1; int i=1; i 1 i<=x i x i++ i++ i {
			if(i%3!=0&&i%5!=0){
				y+=i;
			}
				
		} {
			if(i%3!=0&&i%5!=0){
				y+=i;
			}
				
		} if(i%3!=0&&i%5!=0){
				y+=i;
			} i%3!=0&&i%5!=0 i%3!=0 i%3 i 3 0 i%5!=0 i%5 i 5 0 {
				y+=i;
			} y+=i y i System.out.print(y) System.out.print System.out System System.out y String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y=0;
		for(int i=1;i<=x;i++){
			if(i%3!=0&&i%5!=0){
				y+=i;
			}
				
		}
			System.out.print(y);

		

	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y=0;
		for(int i=1;i<=x;i++){
			if(i%3!=0&&i%5!=0){
				y+=i;
			}
				
		}
			System.out.print(y);

		

	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y=0;
		for(int i=1;i<=x;i++){
			if(i%3!=0&&i%5!=0){
				y+=i;
			}
				
		}
			System.out.print(y);

		

	}
}