import java.util.*;
class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int N = sc.nextInt();
      long n = N;
        long ans = 0;
        for(long i=1;i<=N;i++){
        if(((i%3)!=0)&&((i%5)!=0))
        ans= ans+i;
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int N = sc.nextInt();
      long n = N;
        long ans = 0;
        for(long i=1;i<=N;i++){
        if(((i%3)!=0)&&((i%5)!=0))
        ans= ans+i;
        }
        System.out.println(ans);
    }
} Main static Scanner sc=new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args){
        int N = sc.nextInt();
      long n = N;
        long ans = 0;
        for(long i=1;i<=N;i++){
        if(((i%3)!=0)&&((i%5)!=0))
        ans= ans+i;
        }
        System.out.println(ans);
    } main {
        int N = sc.nextInt();
      long n = N;
        long ans = 0;
        for(long i=1;i<=N;i++){
        if(((i%3)!=0)&&((i%5)!=0))
        ans= ans+i;
        }
        System.out.println(ans);
    } int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long n = N; n N long ans = 0; ans 0 for(long i=1;i<=N;i++){
        if(((i%3)!=0)&&((i%5)!=0))
        ans= ans+i;
        } long i=1; long i=1; i 1 i<=N i N i++ i++ i {
        if(((i%3)!=0)&&((i%5)!=0))
        ans= ans+i;
        } {
        if(((i%3)!=0)&&((i%5)!=0))
        ans= ans+i;
        } if(((i%3)!=0)&&((i%5)!=0))
        ans= ans+i; ((i%3)!=0)&&((i%5)!=0) ((i%3)!=0) (i%3) i 3 0 ((i%5)!=0) (i%5) i 5 0 ans= ans+i ans 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{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int N = sc.nextInt();
      long n = N;
        long ans = 0;
        for(long i=1;i<=N;i++){
        if(((i%3)!=0)&&((i%5)!=0))
        ans= ans+i;
        }
        System.out.println(ans);
    }
}