import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long da[] = new long[N];
        long ans = 0;
        for(int i = 0;i<N;i++){
            da[i]=i+1;
        }
        for(int i=0;i<N;i++){
            if((da[i]%3!=0)&&(da[i]%5!=0)){
                ans = ans +da[i];
            }
        }
        System.out.println(ans);
    }

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

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long da[] = new long[N];
        long ans = 0;
        for(int i = 0;i<N;i++){
            da[i]=i+1;
        }
        for(int i=0;i<N;i++){
            if((da[i]%3!=0)&&(da[i]%5!=0)){
                ans = ans +da[i];
            }
        }
        System.out.println(ans);
    }

} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long da[] = new long[N];
        long ans = 0;
        for(int i = 0;i<N;i++){
            da[i]=i+1;
        }
        for(int i=0;i<N;i++){
            if((da[i]%3!=0)&&(da[i]%5!=0)){
                ans = ans +da[i];
            }
        }
        System.out.println(ans);
    } main {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long da[] = new long[N];
        long ans = 0;
        for(int i = 0;i<N;i++){
            da[i]=i+1;
        }
        for(int i=0;i<N;i++){
            if((da[i]%3!=0)&&(da[i]%5!=0)){
                ans = ans +da[i];
            }
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long da[] = new long[N]; da new long[N] N long ans = 0; ans 0 for(int i = 0;i<N;i++){
            da[i]=i+1;
        } int i = 0; int i = 0; i 0 i<N i N i++ i++ i {
            da[i]=i+1;
        } {
            da[i]=i+1;
        } da[i]=i+1 da[i] da i i+1 i 1 for(int i=0;i<N;i++){
            if((da[i]%3!=0)&&(da[i]%5!=0)){
                ans = ans +da[i];
            }
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            if((da[i]%3!=0)&&(da[i]%5!=0)){
                ans = ans +da[i];
            }
        } {
            if((da[i]%3!=0)&&(da[i]%5!=0)){
                ans = ans +da[i];
            }
        } if((da[i]%3!=0)&&(da[i]%5!=0)){
                ans = ans +da[i];
            } (da[i]%3!=0)&&(da[i]%5!=0) (da[i]%3!=0) da[i]%3 da[i] da i 3 0 (da[i]%5!=0) da[i]%5 da[i] da i 5 0 {
                ans = ans +da[i];
            } ans = ans +da[i] ans ans +da[i] ans da[i] da i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long da[] = new long[N];
        long ans = 0;
        for(int i = 0;i<N;i++){
            da[i]=i+1;
        }
        for(int i=0;i<N;i++){
            if((da[i]%3!=0)&&(da[i]%5!=0)){
                ans = ans +da[i];
            }
        }
        System.out.println(ans);
    }

} public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long da[] = new long[N];
        long ans = 0;
        for(int i = 0;i<N;i++){
            da[i]=i+1;
        }
        for(int i=0;i<N;i++){
            if((da[i]%3!=0)&&(da[i]%5!=0)){
                ans = ans +da[i];
            }
        }
        System.out.println(ans);
    }

} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long da[] = new long[N];
        long ans = 0;
        for(int i = 0;i<N;i++){
            da[i]=i+1;
        }
        for(int i=0;i<N;i++){
            if((da[i]%3!=0)&&(da[i]%5!=0)){
                ans = ans +da[i];
            }
        }
        System.out.println(ans);
    }

}