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

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        long ans = 0;
        
        for(int i = 1; i <= n; i++){
            if((i % 3 != 0) && (i % 5 != 0)){
                ans += i;
            }
        }
         
        out.println(ans);
        out.close();
        
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        long ans = 0;
        
        for(int i = 1; i <= n; i++){
            if((i % 3 != 0) && (i % 5 != 0)){
                ans += i;
            }
        }
         
        out.println(ans);
        out.close();
        
    }
} Main public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        long ans = 0;
        
        for(int i = 1; i <= n; i++){
            if((i % 3 != 0) && (i % 5 != 0)){
                ans += i;
            }
        }
         
        out.println(ans);
        out.close();
        
    } main {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        long ans = 0;
        
        for(int i = 1; i <= n; i++){
            if((i % 3 != 0) && (i % 5 != 0)){
                ans += i;
            }
        }
         
        out.println(ans);
        out.close();
        
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); out new PrintWriter(new OutputStreamWriter(System.out)) int n = Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br long ans = 0; ans 0 for(int i = 1; i <= n; i++){
            if((i % 3 != 0) && (i % 5 != 0)){
                ans += i;
            }
        } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
            if((i % 3 != 0) && (i % 5 != 0)){
                ans += i;
            }
        } {
            if((i % 3 != 0) && (i % 5 != 0)){
                ans += i;
            }
        } if((i % 3 != 0) && (i % 5 != 0)){
                ans += i;
            } (i % 3 != 0) && (i % 5 != 0) (i % 3 != 0) i % 3 i 3 0 (i % 5 != 0) i % 5 i 5 0 {
                ans += i;
            } ans += i ans i out.println(ans) out.println out ans out.close() out.close out String[] args args public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        long ans = 0;
        
        for(int i = 1; i <= n; i++){
            if((i % 3 != 0) && (i % 5 != 0)){
                ans += i;
            }
        }
         
        out.println(ans);
        out.close();
        
    }
} public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        long ans = 0;
        
        for(int i = 1; i <= n; i++){
            if((i % 3 != 0) && (i % 5 != 0)){
                ans += i;
            }
        }
         
        out.println(ans);
        out.close();
        
    }
} Main
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        long ans = 0;
        
        for(int i = 1; i <= n; i++){
            if((i % 3 != 0) && (i % 5 != 0)){
                ans += i;
            }
        }
         
        out.println(ans);
        out.close();
        
    }
}