import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        long N = sn.nextInt();
        long result = 0;

        for(int i=1; i<=N; i++){
            if(i%3 == 0 | i%5 == 0){
                continue;
            }else{
                result += i;
            }
        }

        System.out.println(result);
    }
} import java.util.*; util.* java public class Main{
    public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        long N = sn.nextInt();
        long result = 0;

        for(int i=1; i<=N; i++){
            if(i%3 == 0 | i%5 == 0){
                continue;
            }else{
                result += i;
            }
        }

        System.out.println(result);
    }
} Main public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        long N = sn.nextInt();
        long result = 0;

        for(int i=1; i<=N; i++){
            if(i%3 == 0 | i%5 == 0){
                continue;
            }else{
                result += i;
            }
        }

        System.out.println(result);
    } main {
        Scanner sn = new Scanner(System.in);
        long N = sn.nextInt();
        long result = 0;

        for(int i=1; i<=N; i++){
            if(i%3 == 0 | i%5 == 0){
                continue;
            }else{
                result += i;
            }
        }

        System.out.println(result);
    } Scanner sn = new Scanner(System.in); sn new Scanner(System.in) long N = sn.nextInt(); N sn.nextInt() sn.nextInt sn long result = 0; result 0 for(int i=1; i<=N; i++){
            if(i%3 == 0 | i%5 == 0){
                continue;
            }else{
                result += i;
            }
        } int i=1; int i=1; i 1 i<=N i N i++ i++ i {
            if(i%3 == 0 | i%5 == 0){
                continue;
            }else{
                result += i;
            }
        } {
            if(i%3 == 0 | i%5 == 0){
                continue;
            }else{
                result += i;
            }
        } if(i%3 == 0 | i%5 == 0){
                continue;
            }else{
                result += i;
            } i%3 == 0 | i%5 == 0 i%3 == 0 i%3 i 3 0 i%5 == 0 i%5 i 5 0 {
                continue;
            } continue; {
                result += i;
            } result += i result i System.out.println(result) System.out.println System.out System System.out result String args[] args public class Main{
    public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        long N = sn.nextInt();
        long result = 0;

        for(int i=1; i<=N; i++){
            if(i%3 == 0 | i%5 == 0){
                continue;
            }else{
                result += i;
            }
        }

        System.out.println(result);
    }
} public class Main{
    public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        long N = sn.nextInt();
        long result = 0;

        for(int i=1; i<=N; i++){
            if(i%3 == 0 | i%5 == 0){
                continue;
            }else{
                result += i;
            }
        }

        System.out.println(result);
    }
} Main
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        long N = sn.nextInt();
        long result = 0;

        for(int i=1; i<=N; i++){
            if(i%3 == 0 | i%5 == 0){
                continue;
            }else{
                result += i;
            }
        }

        System.out.println(result);
    }
}