import java.util.Scanner;
//import java.util.Random;

class Main{
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		
		final int n=stdIn.nextInt();
		long ans=0;
		for(int i=1;i<=n;++i){
			if(i%3==0 || i%5==0){}
			else ans+=i;
		}
		
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		
		final int n=stdIn.nextInt();
		long ans=0;
		for(int i=1;i<=n;++i){
			if(i%3==0 || i%5==0){}
			else ans+=i;
		}
		
		System.out.println(ans);
	}
} Main public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		
		final int n=stdIn.nextInt();
		long ans=0;
		for(int i=1;i<=n;++i){
			if(i%3==0 || i%5==0){}
			else ans+=i;
		}
		
		System.out.println(ans);
	} main {
		Scanner stdIn=new Scanner(System.in);
		
		final int n=stdIn.nextInt();
		long ans=0;
		for(int i=1;i<=n;++i){
			if(i%3==0 || i%5==0){}
			else ans+=i;
		}
		
		System.out.println(ans);
	} Scanner stdIn=new Scanner(System.in); stdIn new Scanner(System.in) final int n=stdIn.nextInt(); n stdIn.nextInt() stdIn.nextInt stdIn long ans=0; ans 0 for(int i=1;i<=n;++i){
			if(i%3==0 || i%5==0){}
			else ans+=i;
		} int i=1; int i=1; i 1 i<=n i n ++i ++i i {
			if(i%3==0 || i%5==0){}
			else ans+=i;
		} {
			if(i%3==0 || i%5==0){}
			else ans+=i;
		} if(i%3==0 || i%5==0){}
			else 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+=i ans i System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.Scanner;
//import java.util.Random;

class Main{
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		
		final int n=stdIn.nextInt();
		long ans=0;
		for(int i=1;i<=n;++i){
			if(i%3==0 || i%5==0){}
			else ans+=i;
		}
		
		System.out.println(ans);
	}
}