import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // write your code here

        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = in.nextInt();

        long ans = 0;

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

        out.println(ans);
        out.close();


    }
} import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        // write your code here

        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = in.nextInt();

        long ans = 0;

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

        out.println(ans);
        out.close();


    }
} Main public static void main(String[] args) {
        // write your code here

        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = in.nextInt();

        long ans = 0;

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

        out.println(ans);
        out.close();


    } main {
        // write your code here

        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = in.nextInt();

        long ans = 0;

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

        out.println(ans);
        out.close();


    } Scanner in = new Scanner(System.in); in new Scanner(System.in) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int N = in.nextInt(); N in.nextInt() in.nextInt in long ans = 0; ans 0 for (int i = 1; i <= N; i++) {
            if(i % 5 == 0 && i % 3 == 0) continue;
            if(i % 5 == 0 || i % 3 == 0) continue;
            ans+= i;
        } int i = 1; int i = 1; i 1 i <= N i N i++ i++ i {
            if(i % 5 == 0 && i % 3 == 0) continue;
            if(i % 5 == 0 || i % 3 == 0) continue;
            ans+= i;
        } {
            if(i % 5 == 0 && i % 3 == 0) continue;
            if(i % 5 == 0 || i % 3 == 0) continue;
            ans+= i;
        } if(i % 5 == 0 && i % 3 == 0) continue; i % 5 == 0 && i % 3 == 0 i % 5 == 0 i % 5 i 5 0 i % 3 == 0 i % 3 i 3 0 continue; if(i % 5 == 0 || i % 3 == 0) continue; i % 5 == 0 || i % 3 == 0 i % 5 == 0 i % 5 i 5 0 i % 3 == 0 i % 3 i 3 0 continue; 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) {
        // write your code here

        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = in.nextInt();

        long ans = 0;

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

        out.println(ans);
        out.close();


    }
} public class Main {
    public static void main(String[] args) {
        // write your code here

        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = in.nextInt();

        long ans = 0;

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

        out.println(ans);
        out.close();


    }
} Main
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // write your code here

        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = in.nextInt();

        long ans = 0;

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

        out.println(ans);
        out.close();


    }
}
