import java.math.BigInteger;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger a = BigInteger.ZERO;
        for (int i = 0; i < n+1; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                a = a.add(new BigInteger(""+i));
            }
        }
        System.out.println(a.toString());

    }
} import java.math.BigInteger; BigInteger java.math import java.util.HashSet; HashSet java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger a = BigInteger.ZERO;
        for (int i = 0; i < n+1; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                a = a.add(new BigInteger(""+i));
            }
        }
        System.out.println(a.toString());

    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger a = BigInteger.ZERO;
        for (int i = 0; i < n+1; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                a = a.add(new BigInteger(""+i));
            }
        }
        System.out.println(a.toString());

    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger a = BigInteger.ZERO;
        for (int i = 0; i < n+1; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                a = a.add(new BigInteger(""+i));
            }
        }
        System.out.println(a.toString());

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc BigInteger a = BigInteger.ZERO; a BigInteger.ZERO BigInteger BigInteger.ZERO for (int i = 0; i < n+1; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                a = a.add(new BigInteger(""+i));
            }
        } int i = 0; int i = 0; i 0 i < n+1 i n+1 n 1 i++ i++ i {
            if (i % 3 != 0 && i % 5 != 0) {
                a = a.add(new BigInteger(""+i));
            }
        } {
            if (i % 3 != 0 && i % 5 != 0) {
                a = a.add(new BigInteger(""+i));
            }
        } if (i % 3 != 0 && i % 5 != 0) {
                a = a.add(new BigInteger(""+i));
            } i % 3 != 0 && i % 5 != 0 i % 3 != 0 i % 3 i 3 0 i % 5 != 0 i % 5 i 5 0 {
                a = a.add(new BigInteger(""+i));
            } a = a.add(new BigInteger(""+i)) a a.add(new BigInteger(""+i)) a.add a new BigInteger(""+i) System.out.println(a.toString()) System.out.println System.out System System.out a.toString() a.toString a String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger a = BigInteger.ZERO;
        for (int i = 0; i < n+1; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                a = a.add(new BigInteger(""+i));
            }
        }
        System.out.println(a.toString());

    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger a = BigInteger.ZERO;
        for (int i = 0; i < n+1; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                a = a.add(new BigInteger(""+i));
            }
        }
        System.out.println(a.toString());

    }
} Main
import java.math.BigInteger;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger a = BigInteger.ZERO;
        for (int i = 0; i < n+1; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                a = a.add(new BigInteger(""+i));
            }
        }
        System.out.println(a.toString());

    }
}
