import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long Sum = 0;
        
        for(int i=1; i<=N; i++){
            if(!(i%3==0||i%5==0||i%15==0)){
                Sum += i;
            }
        }
    
        System.out.println(Sum);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long Sum = 0;
        
        for(int i=1; i<=N; i++){
            if(!(i%3==0||i%5==0||i%15==0)){
                Sum += i;
            }
        }
    
        System.out.println(Sum);
    }
} Main public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long Sum = 0;
        
        for(int i=1; i<=N; i++){
            if(!(i%3==0||i%5==0||i%15==0)){
                Sum += i;
            }
        }
    
        System.out.println(Sum);
    } main {
        
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long Sum = 0;
        
        for(int i=1; i<=N; i++){
            if(!(i%3==0||i%5==0||i%15==0)){
                Sum += i;
            }
        }
    
        System.out.println(Sum);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner long Sum = 0; Sum 0 for(int i=1; i<=N; i++){
            if(!(i%3==0||i%5==0||i%15==0)){
                Sum += i;
            }
        } int i=1; int i=1; i 1 i<=N i N i++ i++ i {
            if(!(i%3==0||i%5==0||i%15==0)){
                Sum += i;
            }
        } {
            if(!(i%3==0||i%5==0||i%15==0)){
                Sum += i;
            }
        } if(!(i%3==0||i%5==0||i%15==0)){
                Sum += i;
            } !(i%3==0||i%5==0||i%15==0) (i%3==0||i%5==0||i%15==0) i%3==0||i%5==0||i%15==0 i%3==0 i%3 i 3 0 i%5==0 i%5 i 5 0 i%15==0 i%15 i 15 0 {
                Sum += i;
            } Sum += i Sum 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) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long Sum = 0;
        
        for(int i=1; i<=N; i++){
            if(!(i%3==0||i%5==0||i%15==0)){
                Sum += i;
            }
        }
    
        System.out.println(Sum);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long Sum = 0;
        
        for(int i=1; i<=N; i++){
            if(!(i%3==0||i%5==0||i%15==0)){
                Sum += i;
            }
        }
    
        System.out.println(Sum);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long Sum = 0;
        
        for(int i=1; i<=N; i++){
            if(!(i%3==0||i%5==0||i%15==0)){
                Sum += i;
            }
        }
    
        System.out.println(Sum);
    }
}
