import java.util.*;
import java.io.*;
 
public class Main {
    public static void main (final String[] args) {
        final Scanner s = new Scanner(System.in);
      	int num = Integer.parseInt(s.next());
      
      	long result = 0;
      	
      	for(int i = 1; i <= num; i++) {
          	if(i%3 != 0 && i%5 != 0) result += (long)i;
        }
      	
      	System.out.println(result);
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
    public static void main (final String[] args) {
        final Scanner s = new Scanner(System.in);
      	int num = Integer.parseInt(s.next());
      
      	long result = 0;
      	
      	for(int i = 1; i <= num; i++) {
          	if(i%3 != 0 && i%5 != 0) result += (long)i;
        }
      	
      	System.out.println(result);
    }
} Main public static void main (final String[] args) {
        final Scanner s = new Scanner(System.in);
      	int num = Integer.parseInt(s.next());
      
      	long result = 0;
      	
      	for(int i = 1; i <= num; i++) {
          	if(i%3 != 0 && i%5 != 0) result += (long)i;
        }
      	
      	System.out.println(result);
    } main {
        final Scanner s = new Scanner(System.in);
      	int num = Integer.parseInt(s.next());
      
      	long result = 0;
      	
      	for(int i = 1; i <= num; i++) {
          	if(i%3 != 0 && i%5 != 0) result += (long)i;
        }
      	
      	System.out.println(result);
    } final Scanner s = new Scanner(System.in); s new Scanner(System.in) int num = Integer.parseInt(s.next()); num Integer.parseInt(s.next()) Integer.parseInt Integer s.next() s.next s long result = 0; result 0 for(int i = 1; i <= num; i++) {
          	if(i%3 != 0 && i%5 != 0) result += (long)i;
        } int i = 1; int i = 1; i 1 i <= num i num i++ i++ i {
          	if(i%3 != 0 && i%5 != 0) result += (long)i;
        } {
          	if(i%3 != 0 && i%5 != 0) result += (long)i;
        } if(i%3 != 0 && i%5 != 0) result += (long)i; i%3 != 0 && i%5 != 0 i%3 != 0 i%3 i 3 0 i%5 != 0 i%5 i 5 0 result += (long)i result (long)i System.out.println(result) System.out.println System.out System System.out result final String[] args args public class Main {
    public static void main (final String[] args) {
        final Scanner s = new Scanner(System.in);
      	int num = Integer.parseInt(s.next());
      
      	long result = 0;
      	
      	for(int i = 1; i <= num; i++) {
          	if(i%3 != 0 && i%5 != 0) result += (long)i;
        }
      	
      	System.out.println(result);
    }
} public class Main {
    public static void main (final String[] args) {
        final Scanner s = new Scanner(System.in);
      	int num = Integer.parseInt(s.next());
      
      	long result = 0;
      	
      	for(int i = 1; i <= num; i++) {
          	if(i%3 != 0 && i%5 != 0) result += (long)i;
        }
      	
      	System.out.println(result);
    }
} Main
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main (final String[] args) {
        final Scanner s = new Scanner(System.in);
      	int num = Integer.parseInt(s.next());
      
      	long result = 0;
      	
      	for(int i = 1; i <= num; i++) {
          	if(i%3 != 0 && i%5 != 0) result += (long)i;
        }
      	
      	System.out.println(result);
    }
}