import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   	 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
   	 static int a_dist[];
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        long N = sc.nextLong();
	        
	        
	        long ans=0;
	        for(int i=0;i<=N;i++) {
	        	if(i%3!=0&&i%5!=0) {
	        		ans=ans+i;
	        	}
	        }
	        
	    	System.out.println(ans);
	        
	        	        	        
	 }
} import java.util.*; util.* java import java.util.Map.Entry; Entry java.util.Map class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   	 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
   	 static int a_dist[];
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        long N = sc.nextLong();
	        
	        
	        long ans=0;
	        for(int i=0;i<=N;i++) {
	        	if(i%3!=0&&i%5!=0) {
	        		ans=ans+i;
	        	}
	        }
	        
	    	System.out.println(ans);
	        
	        	        	        
	 }
} Main static int mod =  (int) (Math.pow(10,9)+7); mod (int) (Math.pow(10,9)+7) Math.pow(10,9) Math.pow Math 10 9 7 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>(); list new ArrayList<ArrayList<Integer>>() static int a_dist[]; a_dist //	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        long N = sc.nextLong();
	        
	        
	        long ans=0;
	        for(int i=0;i<=N;i++) {
	        	if(i%3!=0&&i%5!=0) {
	        		ans=ans+i;
	        	}
	        }
	        
	    	System.out.println(ans);
	        
	        	        	        
	 } main {
	        Scanner sc = new Scanner(System.in);
	        long N = sc.nextLong();
	        
	        
	        long ans=0;
	        for(int i=0;i<=N;i++) {
	        	if(i%3!=0&&i%5!=0) {
	        		ans=ans+i;
	        	}
	        }
	        
	    	System.out.println(ans);
	        
	        	        	        
	 } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long N = sc.nextLong(); N sc.nextLong() sc.nextLong sc long ans=0; ans 0 for(int i=0;i<=N;i++) {
	        	if(i%3!=0&&i%5!=0) {
	        		ans=ans+i;
	        	}
	        } int i=0; int i=0; i 0 i<=N i N i++ i++ i {
	        	if(i%3!=0&&i%5!=0) {
	        		ans=ans+i;
	        	}
	        } {
	        	if(i%3!=0&&i%5!=0) {
	        		ans=ans+i;
	        	}
	        } if(i%3!=0&&i%5!=0) {
	        		ans=ans+i;
	        	} i%3!=0&&i%5!=0 i%3!=0 i%3 i 3 0 i%5!=0 i%5 i 5 0 {
	        		ans=ans+i;
	        	} ans=ans+i ans ans+i ans i System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   	 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
   	 static int a_dist[];
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        long N = sc.nextLong();
	        
	        
	        long ans=0;
	        for(int i=0;i<=N;i++) {
	        	if(i%3!=0&&i%5!=0) {
	        		ans=ans+i;
	        	}
	        }
	        
	    	System.out.println(ans);
	        
	        	        	        
	 }
}
