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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger res = new BigInteger("0");

        for(int i = 1; i <= n; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            res = res.add(BigInteger.valueOf(i));
        }

        System.out.println(res);
    }
} import java.math.BigInteger; BigInteger java.math 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 res = new BigInteger("0");

        for(int i = 1; i <= n; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            res = res.add(BigInteger.valueOf(i));
        }

        System.out.println(res);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger res = new BigInteger("0");

        for(int i = 1; i <= n; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            res = res.add(BigInteger.valueOf(i));
        }

        System.out.println(res);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger res = new BigInteger("0");

        for(int i = 1; i <= n; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            res = res.add(BigInteger.valueOf(i));
        }

        System.out.println(res);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc BigInteger res = new BigInteger("0"); res new BigInteger("0") for(int i = 1; i <= n; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            res = res.add(BigInteger.valueOf(i));
        } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
            if(i % 3 == 0 || i % 5 == 0) continue;
            res = res.add(BigInteger.valueOf(i));
        } {
            if(i % 3 == 0 || i % 5 == 0) continue;
            res = res.add(BigInteger.valueOf(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; res = res.add(BigInteger.valueOf(i)) res res.add(BigInteger.valueOf(i)) res.add res BigInteger.valueOf(i) BigInteger.valueOf BigInteger i System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger res = new BigInteger("0");

        for(int i = 1; i <= n; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            res = res.add(BigInteger.valueOf(i));
        }

        System.out.println(res);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger res = new BigInteger("0");

        for(int i = 1; i <= n; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            res = res.add(BigInteger.valueOf(i));
        }

        System.out.println(res);
    }
} Main
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger res = new BigInteger("0");

        for(int i = 1; i <= n; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            res = res.add(BigInteger.valueOf(i));
        }

        System.out.println(res);
    }
}