import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		long result = 0;

		for(int i=1;i<=N;i++) {
			if(i%3!=0&&i%5!=0) {
				result = result+i;
			}
		}
		System.out.println(result);
	}


}
 import java.util.Scanner; Scanner java.util public class Main{

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		long result = 0;

		for(int i=1;i<=N;i++) {
			if(i%3!=0&&i%5!=0) {
				result = result+i;
			}
		}
		System.out.println(result);
	}


} Main public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		long result = 0;

		for(int i=1;i<=N;i++) {
			if(i%3!=0&&i%5!=0) {
				result = result+i;
			}
		}
		System.out.println(result);
	} main {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		long result = 0;

		for(int i=1;i<=N;i++) {
			if(i%3!=0&&i%5!=0) {
				result = result+i;
			}
		}
		System.out.println(result);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan long result = 0; result 0 for(int i=1;i<=N;i++) {
			if(i%3!=0&&i%5!=0) {
				result = result+i;
			}
		} int i=1; int i=1; i 1 i<=N i N i++ i++ i {
			if(i%3!=0&&i%5!=0) {
				result = result+i;
			}
		} {
			if(i%3!=0&&i%5!=0) {
				result = result+i;
			}
		} if(i%3!=0&&i%5!=0) {
				result = result+i;
			} i%3!=0&&i%5!=0 i%3!=0 i%3 i 3 0 i%5!=0 i%5 i 5 0 {
				result = result+i;
			} result = result+i result result+i result i System.out.println(result) System.out.println System.out System System.out result String args[] args public class Main{

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		long result = 0;

		for(int i=1;i<=N;i++) {
			if(i%3!=0&&i%5!=0) {
				result = result+i;
			}
		}
		System.out.println(result);
	}


} public class Main{

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		long result = 0;

		for(int i=1;i<=N;i++) {
			if(i%3!=0&&i%5!=0) {
				result = result+i;
			}
		}
		System.out.println(result);
	}


} Main
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		long result = 0;

		for(int i=1;i<=N;i++) {
			if(i%3!=0&&i%5!=0) {
				result = result+i;
			}
		}
		System.out.println(result);
	}


}

