import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		
		ArrayList<Long> list=new ArrayList<>();
		
		long num=1;
		
		while(num!=n+1)
		{
			if(num%3!=0&&num%5!=0)
			{
				list.add(num);
				num++;
			}
			else
			{
				num++;
			}
		}
		
		long sum=0;
		
		for(int i=0;i<list.size();i++)
		{
			sum=sum+list.get(i);
		}
		
		System.out.println(sum);
		
	}
	
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		
		ArrayList<Long> list=new ArrayList<>();
		
		long num=1;
		
		while(num!=n+1)
		{
			if(num%3!=0&&num%5!=0)
			{
				list.add(num);
				num++;
			}
			else
			{
				num++;
			}
		}
		
		long sum=0;
		
		for(int i=0;i<list.size();i++)
		{
			sum=sum+list.get(i);
		}
		
		System.out.println(sum);
		
	}
	
} Main public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		
		ArrayList<Long> list=new ArrayList<>();
		
		long num=1;
		
		while(num!=n+1)
		{
			if(num%3!=0&&num%5!=0)
			{
				list.add(num);
				num++;
			}
			else
			{
				num++;
			}
		}
		
		long sum=0;
		
		for(int i=0;i<list.size();i++)
		{
			sum=sum+list.get(i);
		}
		
		System.out.println(sum);
		
	} main {
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		
		ArrayList<Long> list=new ArrayList<>();
		
		long num=1;
		
		while(num!=n+1)
		{
			if(num%3!=0&&num%5!=0)
			{
				list.add(num);
				num++;
			}
			else
			{
				num++;
			}
		}
		
		long sum=0;
		
		for(int i=0;i<list.size();i++)
		{
			sum=sum+list.get(i);
		}
		
		System.out.println(sum);
		
	} Scanner s=new Scanner(System.in); s new Scanner(System.in) int n=s.nextInt(); n s.nextInt() s.nextInt s ArrayList<Long> list=new ArrayList<>(); list new ArrayList<>() long num=1; num 1 while(num!=n+1)
		{
			if(num%3!=0&&num%5!=0)
			{
				list.add(num);
				num++;
			}
			else
			{
				num++;
			}
		} num!=n+1 num n+1 n 1 {
			if(num%3!=0&&num%5!=0)
			{
				list.add(num);
				num++;
			}
			else
			{
				num++;
			}
		} if(num%3!=0&&num%5!=0)
			{
				list.add(num);
				num++;
			}
			else
			{
				num++;
			} num%3!=0&&num%5!=0 num%3!=0 num%3 num 3 0 num%5!=0 num%5 num 5 0 {
				list.add(num);
				num++;
			} list.add(num) list.add list num num++ num {
				num++;
			} num++ num long sum=0; sum 0 for(int i=0;i<list.size();i++)
		{
			sum=sum+list.get(i);
		} int i=0; int i=0; i 0 i<list.size() i list.size() list.size list i++ i++ i {
			sum=sum+list.get(i);
		} {
			sum=sum+list.get(i);
		} sum=sum+list.get(i) sum sum+list.get(i) sum list.get(i) list.get list i System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		
		ArrayList<Long> list=new ArrayList<>();
		
		long num=1;
		
		while(num!=n+1)
		{
			if(num%3!=0&&num%5!=0)
			{
				list.add(num);
				num++;
			}
			else
			{
				num++;
			}
		}
		
		long sum=0;
		
		for(int i=0;i<list.size();i++)
		{
			sum=sum+list.get(i);
		}
		
		System.out.println(sum);
		
	}
	
} public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		
		ArrayList<Long> list=new ArrayList<>();
		
		long num=1;
		
		while(num!=n+1)
		{
			if(num%3!=0&&num%5!=0)
			{
				list.add(num);
				num++;
			}
			else
			{
				num++;
			}
		}
		
		long sum=0;
		
		for(int i=0;i<list.size();i++)
		{
			sum=sum+list.get(i);
		}
		
		System.out.println(sum);
		
	}
	
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		
		ArrayList<Long> list=new ArrayList<>();
		
		long num=1;
		
		while(num!=n+1)
		{
			if(num%3!=0&&num%5!=0)
			{
				list.add(num);
				num++;
			}
			else
			{
				num++;
			}
		}
		
		long sum=0;
		
		for(int i=0;i<list.size();i++)
		{
			sum=sum+list.get(i);
		}
		
		System.out.println(sum);
		
	}
	
}
