import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
  		long ans=0;

  		int[] a=new int[n];
		for(int c=1;c<n+1;c++){
    		if(c%3!=0&&c%5!=0){
              ans+=c;
            }
    	}
    
 	

    	System.out.println(ans);
    }
} import java.util.*; util.* java class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
  		long ans=0;

  		int[] a=new int[n];
		for(int c=1;c<n+1;c++){
    		if(c%3!=0&&c%5!=0){
              ans+=c;
            }
    	}
    
 	

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

  		int[] a=new int[n];
		for(int c=1;c<n+1;c++){
    		if(c%3!=0&&c%5!=0){
              ans+=c;
            }
    	}
    
 	

    	System.out.println(ans);
    } main {
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
  		long ans=0;

  		int[] a=new int[n];
		for(int c=1;c<n+1;c++){
    		if(c%3!=0&&c%5!=0){
              ans+=c;
            }
    	}
    
 	

    	System.out.println(ans);
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc long ans=0; ans 0 int[] a=new int[n]; a new int[n] n for(int c=1;c<n+1;c++){
    		if(c%3!=0&&c%5!=0){
              ans+=c;
            }
    	} int c=1; int c=1; c 1 c<n+1 c n+1 n 1 c++ c++ c {
    		if(c%3!=0&&c%5!=0){
              ans+=c;
            }
    	} {
    		if(c%3!=0&&c%5!=0){
              ans+=c;
            }
    	} if(c%3!=0&&c%5!=0){
              ans+=c;
            } c%3!=0&&c%5!=0 c%3!=0 c%3 c 3 0 c%5!=0 c%5 c 5 0 {
              ans+=c;
            } ans+=c ans c System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
  		long ans=0;

  		int[] a=new int[n];
		for(int c=1;c<n+1;c++){
    		if(c%3!=0&&c%5!=0){
              ans+=c;
            }
    	}
    
 	

    	System.out.println(ans);
    }
}
