import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

public class Main	 {
    public static void main(String[] args) throws IOException {
        	Scanner sc = new Scanner(System.in);
        	long n = sc.nextLong();
        	long res =0;
        	for(int i=1;i<=n;i++) {
        		if(i%3!=0 && i%5!=0)
        			res=res+i;
        	}
        	System.out.println(res);
    }
} import java.io.*; io.* java import java.math.*; math.* java import java.text.*; text.* java import java.util.*; util.* java import java.util.regex.*; regex.* java.util public class Main	 {
    public static void main(String[] args) throws IOException {
        	Scanner sc = new Scanner(System.in);
        	long n = sc.nextLong();
        	long res =0;
        	for(int i=1;i<=n;i++) {
        		if(i%3!=0 && i%5!=0)
        			res=res+i;
        	}
        	System.out.println(res);
    }
} Main public static void main(String[] args) throws IOException {
        	Scanner sc = new Scanner(System.in);
        	long n = sc.nextLong();
        	long res =0;
        	for(int i=1;i<=n;i++) {
        		if(i%3!=0 && i%5!=0)
        			res=res+i;
        	}
        	System.out.println(res);
    } main {
        	Scanner sc = new Scanner(System.in);
        	long n = sc.nextLong();
        	long res =0;
        	for(int i=1;i<=n;i++) {
        		if(i%3!=0 && i%5!=0)
        			res=res+i;
        	}
        	System.out.println(res);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long n = sc.nextLong(); n sc.nextLong() sc.nextLong sc long res =0; res 0 for(int i=1;i<=n;i++) {
        		if(i%3!=0 && i%5!=0)
        			res=res+i;
        	} int i=1; int i=1; i 1 i<=n i n i++ i++ i {
        		if(i%3!=0 && i%5!=0)
        			res=res+i;
        	} {
        		if(i%3!=0 && i%5!=0)
        			res=res+i;
        	} if(i%3!=0 && i%5!=0)
        			res=res+i; i%3!=0 && i%5!=0 i%3!=0 i%3 i 3 0 i%5!=0 i%5 i 5 0 res=res+i res res+i res i System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main	 {
    public static void main(String[] args) throws IOException {
        	Scanner sc = new Scanner(System.in);
        	long n = sc.nextLong();
        	long res =0;
        	for(int i=1;i<=n;i++) {
        		if(i%3!=0 && i%5!=0)
        			res=res+i;
        	}
        	System.out.println(res);
    }
} public class Main	 {
    public static void main(String[] args) throws IOException {
        	Scanner sc = new Scanner(System.in);
        	long n = sc.nextLong();
        	long res =0;
        	for(int i=1;i<=n;i++) {
        		if(i%3!=0 && i%5!=0)
        			res=res+i;
        	}
        	System.out.println(res);
    }
} Main
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

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