import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int max = sc.nextInt();
		
		long result = 0;
		
		for(long l = 1; l <= max; l++){
		
			if(!(l%15 == 0) && !(l%5 == 0) && !(l%3 == 0)) {
				
				result += l;
				
			}
		
        }
          
		sc.close();
		
      	System.out.println(result);
      
	}
	
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int max = sc.nextInt();
		
		long result = 0;
		
		for(long l = 1; l <= max; l++){
		
			if(!(l%15 == 0) && !(l%5 == 0) && !(l%3 == 0)) {
				
				result += l;
				
			}
		
        }
          
		sc.close();
		
      	System.out.println(result);
      
	}
	
} Main public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int max = sc.nextInt();
		
		long result = 0;
		
		for(long l = 1; l <= max; l++){
		
			if(!(l%15 == 0) && !(l%5 == 0) && !(l%3 == 0)) {
				
				result += l;
				
			}
		
        }
          
		sc.close();
		
      	System.out.println(result);
      
	} main {
		
		Scanner sc = new Scanner(System.in);
		
		int max = sc.nextInt();
		
		long result = 0;
		
		for(long l = 1; l <= max; l++){
		
			if(!(l%15 == 0) && !(l%5 == 0) && !(l%3 == 0)) {
				
				result += l;
				
			}
		
        }
          
		sc.close();
		
      	System.out.println(result);
      
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int max = sc.nextInt(); max sc.nextInt() sc.nextInt sc long result = 0; result 0 for(long l = 1; l <= max; l++){
		
			if(!(l%15 == 0) && !(l%5 == 0) && !(l%3 == 0)) {
				
				result += l;
				
			}
		
        } long l = 1; long l = 1; l 1 l <= max l max l++ l++ l {
		
			if(!(l%15 == 0) && !(l%5 == 0) && !(l%3 == 0)) {
				
				result += l;
				
			}
		
        } {
		
			if(!(l%15 == 0) && !(l%5 == 0) && !(l%3 == 0)) {
				
				result += l;
				
			}
		
        } if(!(l%15 == 0) && !(l%5 == 0) && !(l%3 == 0)) {
				
				result += l;
				
			} !(l%15 == 0) && !(l%5 == 0) && !(l%3 == 0) !(l%15 == 0) && !(l%5 == 0) && !(l%3 == 0) !(l%15 == 0) (l%15 == 0) l%15 l 15 0 !(l%5 == 0) (l%5 == 0) l%5 l 5 0 !(l%3 == 0) (l%3 == 0) l%3 l 3 0 {
				
				result += l;
				
			} result += l result l sc.close() sc.close sc System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int max = sc.nextInt();
		
		long result = 0;
		
		for(long l = 1; l <= max; l++){
		
			if(!(l%15 == 0) && !(l%5 == 0) && !(l%3 == 0)) {
				
				result += l;
				
			}
		
        }
          
		sc.close();
		
      	System.out.println(result);
      
	}
	
} public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int max = sc.nextInt();
		
		long result = 0;
		
		for(long l = 1; l <= max; l++){
		
			if(!(l%15 == 0) && !(l%5 == 0) && !(l%3 == 0)) {
				
				result += l;
				
			}
		
        }
          
		sc.close();
		
      	System.out.println(result);
      
	}
	
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int max = sc.nextInt();
		
		long result = 0;
		
		for(long l = 1; l <= max; l++){
		
			if(!(l%15 == 0) && !(l%5 == 0) && !(l%3 == 0)) {
				
				result += l;
				
			}
		
        }
          
		sc.close();
		
      	System.out.println(result);
      
	}
	
}