
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();

        long ans = 0;
        for(int i = 1; i <= N; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            ans += i;
        }

        os.println(ans);
    }

} import java.io.InputStream; InputStream java.io import java.io.PrintStream; PrintStream java.io import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();

        long ans = 0;
        for(int i = 1; i <= N; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            ans += i;
        }

        os.println(ans);
    }

} Main public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    } main {
        solve(System.in, System.out);
    } solve(System.in, System.out) solve System.in System System.in System.out System System.out String[] args args static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();

        long ans = 0;
        for(int i = 1; i <= N; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            ans += i;
        }

        os.println(ans);
    } solve {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();

        long ans = 0;
        for(int i = 1; i <= N; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            ans += i;
        }

        os.println(ans);
    } Scanner scan = new Scanner(is); scan new Scanner(is) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan long ans = 0; ans 0 for(int i = 1; i <= N; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            ans += i;
        } int i = 1; int i = 1; i 1 i <= N i N i++ i++ i {
            if(i % 3 == 0 || i % 5 == 0) continue;
            ans += i;
        } {
            if(i % 3 == 0 || i % 5 == 0) continue;
            ans += i;
        } if(i % 3 == 0 || i % 5 == 0) continue; i % 3 == 0 || i % 5 == 0 i % 3 == 0 i % 3 i 3 0 i % 5 == 0 i % 5 i 5 0 continue; ans += i ans i os.println(ans) os.println os ans InputStream is is PrintStream os os public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();

        long ans = 0;
        for(int i = 1; i <= N; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            ans += i;
        }

        os.println(ans);
    }

} public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();

        long ans = 0;
        for(int i = 1; i <= N; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            ans += i;
        }

        os.println(ans);
    }

} Main

import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();

        long ans = 0;
        for(int i = 1; i <= N; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            ans += i;
        }

        os.println(ans);
    }

}