import java.io.*;
import java.util.Scanner;

public class Main{

	static long n;
	public static void main(String args[])throws Exception{
		Scanner sc=new Scanner(System.in);
			 n= sc.nextLong();
			 long sum=0;
			for(int i=1;i<=n;i++){
				if(i%3==0 || i%5==0){
					continue;
				}
				else
					sum+=i;
			}
			System.out.print(sum);
		}
	}
 import java.io.*; io.* java import java.util.Scanner; Scanner java.util public class Main{

	static long n;
	public static void main(String args[])throws Exception{
		Scanner sc=new Scanner(System.in);
			 n= sc.nextLong();
			 long sum=0;
			for(int i=1;i<=n;i++){
				if(i%3==0 || i%5==0){
					continue;
				}
				else
					sum+=i;
			}
			System.out.print(sum);
		}
	} Main static long n; n public static void main(String args[])throws Exception{
		Scanner sc=new Scanner(System.in);
			 n= sc.nextLong();
			 long sum=0;
			for(int i=1;i<=n;i++){
				if(i%3==0 || i%5==0){
					continue;
				}
				else
					sum+=i;
			}
			System.out.print(sum);
		} main {
		Scanner sc=new Scanner(System.in);
			 n= sc.nextLong();
			 long sum=0;
			for(int i=1;i<=n;i++){
				if(i%3==0 || i%5==0){
					continue;
				}
				else
					sum+=i;
			}
			System.out.print(sum);
		} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) n= sc.nextLong() n sc.nextLong() sc.nextLong sc long sum=0; sum 0 for(int i=1;i<=n;i++){
				if(i%3==0 || i%5==0){
					continue;
				}
				else
					sum+=i;
			} int i=1; int i=1; i 1 i<=n i n i++ i++ i {
				if(i%3==0 || i%5==0){
					continue;
				}
				else
					sum+=i;
			} {
				if(i%3==0 || i%5==0){
					continue;
				}
				else
					sum+=i;
			} if(i%3==0 || i%5==0){
					continue;
				}
				else
					sum+=i; i%3==0 || i%5==0 i%3==0 i%3 i 3 0 i%5==0 i%5 i 5 0 {
					continue;
				} continue; sum+=i sum i System.out.print(sum) System.out.print System.out System System.out sum String args[] args public class Main{

	static long n;
	public static void main(String args[])throws Exception{
		Scanner sc=new Scanner(System.in);
			 n= sc.nextLong();
			 long sum=0;
			for(int i=1;i<=n;i++){
				if(i%3==0 || i%5==0){
					continue;
				}
				else
					sum+=i;
			}
			System.out.print(sum);
		}
	} public class Main{

	static long n;
	public static void main(String args[])throws Exception{
		Scanner sc=new Scanner(System.in);
			 n= sc.nextLong();
			 long sum=0;
			for(int i=1;i<=n;i++){
				if(i%3==0 || i%5==0){
					continue;
				}
				else
					sum+=i;
			}
			System.out.print(sum);
		}
	} Main
import java.io.*;
import java.util.Scanner;

public class Main{

	static long n;
	public static void main(String args[])throws Exception{
		Scanner sc=new Scanner(System.in);
			 n= sc.nextLong();
			 long sum=0;
			for(int i=1;i<=n;i++){
				if(i%3==0 || i%5==0){
					continue;
				}
				else
					sum+=i;
			}
			System.out.print(sum);
		}
	}

