import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner  yomi = new Scanner(System.in);
        long n = yomi.nextLong();
        long a = 0;
        for(long i = 1;i<=n;i++){
            if (i%3!=0 && i%5!=0){
                a = a+i;
            }
        }
        System.out.println(a);


    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner  yomi = new Scanner(System.in);
        long n = yomi.nextLong();
        long a = 0;
        for(long i = 1;i<=n;i++){
            if (i%3!=0 && i%5!=0){
                a = a+i;
            }
        }
        System.out.println(a);


    }
} Main public static void main(String[] args) {
        Scanner  yomi = new Scanner(System.in);
        long n = yomi.nextLong();
        long a = 0;
        for(long i = 1;i<=n;i++){
            if (i%3!=0 && i%5!=0){
                a = a+i;
            }
        }
        System.out.println(a);


    } main {
        Scanner  yomi = new Scanner(System.in);
        long n = yomi.nextLong();
        long a = 0;
        for(long i = 1;i<=n;i++){
            if (i%3!=0 && i%5!=0){
                a = a+i;
            }
        }
        System.out.println(a);


    } Scanner  yomi = new Scanner(System.in); yomi new Scanner(System.in) long n = yomi.nextLong(); n yomi.nextLong() yomi.nextLong yomi long a = 0; a 0 for(long i = 1;i<=n;i++){
            if (i%3!=0 && i%5!=0){
                a = a+i;
            }
        } long i = 1; long i = 1; i 1 i<=n i n i++ i++ i {
            if (i%3!=0 && i%5!=0){
                a = a+i;
            }
        } {
            if (i%3!=0 && i%5!=0){
                a = a+i;
            }
        } if (i%3!=0 && i%5!=0){
                a = a+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+i;
            } a = a+i a a+i a i System.out.println(a) System.out.println System.out System System.out a String[] args args public class Main {

    public static void main(String[] args) {
        Scanner  yomi = new Scanner(System.in);
        long n = yomi.nextLong();
        long a = 0;
        for(long i = 1;i<=n;i++){
            if (i%3!=0 && i%5!=0){
                a = a+i;
            }
        }
        System.out.println(a);


    }
} public class Main {

    public static void main(String[] args) {
        Scanner  yomi = new Scanner(System.in);
        long n = yomi.nextLong();
        long a = 0;
        for(long i = 1;i<=n;i++){
            if (i%3!=0 && i%5!=0){
                a = a+i;
            }
        }
        System.out.println(a);


    }
} Main
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner  yomi = new Scanner(System.in);
        long n = yomi.nextLong();
        long a = 0;
        for(long i = 1;i<=n;i++){
            if (i%3!=0 && i%5!=0){
                a = a+i;
            }
        }
        System.out.println(a);


    }
}
