import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        //System.out.println(a);
        
        //int b = sc.nextInt();
        long temp = 0;
        for(long i=1; i <= a ; i++) {
            if( i%3 == 0 || i%5 == 0 || i%15 == 0){
            }else{
                temp = temp + i;
                //System.out.println(i);
            }
        }
        //System.out.println(String.format("%d",(int)temp));
        System.out.println(temp);

    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        //System.out.println(a);
        
        //int b = sc.nextInt();
        long temp = 0;
        for(long i=1; i <= a ; i++) {
            if( i%3 == 0 || i%5 == 0 || i%15 == 0){
            }else{
                temp = temp + i;
                //System.out.println(i);
            }
        }
        //System.out.println(String.format("%d",(int)temp));
        System.out.println(temp);

    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        //System.out.println(a);
        
        //int b = sc.nextInt();
        long temp = 0;
        for(long i=1; i <= a ; i++) {
            if( i%3 == 0 || i%5 == 0 || i%15 == 0){
            }else{
                temp = temp + i;
                //System.out.println(i);
            }
        }
        //System.out.println(String.format("%d",(int)temp));
        System.out.println(temp);

    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        //System.out.println(a);
        
        //int b = sc.nextInt();
        long temp = 0;
        for(long i=1; i <= a ; i++) {
            if( i%3 == 0 || i%5 == 0 || i%15 == 0){
            }else{
                temp = temp + i;
                //System.out.println(i);
            }
        }
        //System.out.println(String.format("%d",(int)temp));
        System.out.println(temp);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc long temp = 0; temp 0 for(long i=1; i <= a ; i++) {
            if( i%3 == 0 || i%5 == 0 || i%15 == 0){
            }else{
                temp = temp + i;
                //System.out.println(i);
            }
        } long i=1; long i=1; i 1 i <= a i a i++ i++ i {
            if( i%3 == 0 || i%5 == 0 || i%15 == 0){
            }else{
                temp = temp + i;
                //System.out.println(i);
            }
        } {
            if( i%3 == 0 || i%5 == 0 || i%15 == 0){
            }else{
                temp = temp + i;
                //System.out.println(i);
            }
        } if( i%3 == 0 || i%5 == 0 || i%15 == 0){
            }else{
                temp = temp + i;
                //System.out.println(i);
            } i%3 == 0 || i%5 == 0 || i%15 == 0 i%3 == 0 || i%5 == 0 || i%15 == 0 i%3 == 0 i%3 i 3 0 i%5 == 0 i%5 i 5 0 i%15 == 0 i%15 i 15 0 {
            } {
                temp = temp + i;
                //System.out.println(i);
            } temp = temp + i temp temp + i temp i System.out.println(temp) System.out.println System.out System System.out temp String[] args args
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        //System.out.println(a);
        
        //int b = sc.nextInt();
        long temp = 0;
        for(long i=1; i <= a ; i++) {
            if( i%3 == 0 || i%5 == 0 || i%15 == 0){
            }else{
                temp = temp + i;
                //System.out.println(i);
            }
        }
        //System.out.println(String.format("%d",(int)temp));
        System.out.println(temp);

    }
}