import java.util.*;
public final class Main{ 
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in); 
        int n = sc.nextInt();
        long s=0;
        for(int i = 0; i <= n; i++){
            if(i%3!=0 && i%5!=0)
                s+=i;
        }
        System.out.print(s);
    }
}
 import java.util.*; util.* java public final class Main{ 
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in); 
        int n = sc.nextInt();
        long s=0;
        for(int i = 0; i <= n; i++){
            if(i%3!=0 && i%5!=0)
                s+=i;
        }
        System.out.print(s);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in); 
        int n = sc.nextInt();
        long s=0;
        for(int i = 0; i <= n; i++){
            if(i%3!=0 && i%5!=0)
                s+=i;
        }
        System.out.print(s);
    } main {
        Scanner sc = new Scanner(System.in); 
        int n = sc.nextInt();
        long s=0;
        for(int i = 0; i <= n; i++){
            if(i%3!=0 && i%5!=0)
                s+=i;
        }
        System.out.print(s);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long s=0; s 0 for(int i = 0; i <= n; i++){
            if(i%3!=0 && i%5!=0)
                s+=i;
        } int i = 0; int i = 0; i 0 i <= n i n i++ i++ i {
            if(i%3!=0 && i%5!=0)
                s+=i;
        } {
            if(i%3!=0 && i%5!=0)
                s+=i;
        } if(i%3!=0 && i%5!=0)
                s+=i; i%3!=0 && i%5!=0 i%3!=0 i%3 i 3 0 i%5!=0 i%5 i 5 0 s+=i s i System.out.print(s) System.out.print System.out System System.out s String[] args args public final class Main{ 
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in); 
        int n = sc.nextInt();
        long s=0;
        for(int i = 0; i <= n; i++){
            if(i%3!=0 && i%5!=0)
                s+=i;
        }
        System.out.print(s);
    }
} public final class Main{ 
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in); 
        int n = sc.nextInt();
        long s=0;
        for(int i = 0; i <= n; i++){
            if(i%3!=0 && i%5!=0)
                s+=i;
        }
        System.out.print(s);
    }
} Main
import java.util.*;
public final class Main{ 
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in); 
        int n = sc.nextInt();
        long s=0;
        for(int i = 0; i <= n; i++){
            if(i%3!=0 && i%5!=0)
                s+=i;
        }
        System.out.print(s);
    }
}

