import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        long n = input.nextLong();
        long ans = 0;
        for (int i = 1; i < n+1;i++){
            if (i%3 == 0 || i%5 == 0){
                continue;
            } else {
                ans += i;
            }
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        long n = input.nextLong();
        long ans = 0;
        for (int i = 1; i < n+1;i++){
            if (i%3 == 0 || i%5 == 0){
                continue;
            } else {
                ans += i;
            }
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        long n = input.nextLong();
        long ans = 0;
        for (int i = 1; i < n+1;i++){
            if (i%3 == 0 || i%5 == 0){
                continue;
            } else {
                ans += i;
            }
        }
        System.out.println(ans);
    } main {
        Scanner input = new Scanner(System.in);
        long n = input.nextLong();
        long ans = 0;
        for (int i = 1; i < n+1;i++){
            if (i%3 == 0 || i%5 == 0){
                continue;
            } else {
                ans += i;
            }
        }
        System.out.println(ans);
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) long n = input.nextLong(); n input.nextLong() input.nextLong input long ans = 0; ans 0 for (int i = 1; i < n+1;i++){
            if (i%3 == 0 || i%5 == 0){
                continue;
            } else {
                ans += i;
            }
        } int i = 1; int i = 1; i 1 i < n+1 i n+1 n 1 i++ i++ i {
            if (i%3 == 0 || i%5 == 0){
                continue;
            } else {
                ans += i;
            }
        } {
            if (i%3 == 0 || i%5 == 0){
                continue;
            } else {
                ans += i;
            }
        } if (i%3 == 0 || i%5 == 0){
                continue;
            } else {
                ans += i;
            } i%3 == 0 || i%5 == 0 i%3 == 0 i%3 i 3 0 i%5 == 0 i%5 i 5 0 {
                continue;
            } continue; {
                ans += i;
            } ans += i ans i System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        long n = input.nextLong();
        long ans = 0;
        for (int i = 1; i < n+1;i++){
            if (i%3 == 0 || i%5 == 0){
                continue;
            } else {
                ans += i;
            }
        }
        System.out.println(ans);
    }
}