import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long num = sc.nextLong();
        long count = 0;
        for(int i =1 ;i < num+1; i++){
            if(i % 3l == 0l && i % 5l == 0l){
            }else if(i % 3l == 0l){
            }else if(i % 5l == 0l){
            }else{
                count += i;
            }
        }
        System.out.println(count);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long num = sc.nextLong();
        long count = 0;
        for(int i =1 ;i < num+1; i++){
            if(i % 3l == 0l && i % 5l == 0l){
            }else if(i % 3l == 0l){
            }else if(i % 5l == 0l){
            }else{
                count += i;
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long num = sc.nextLong();
        long count = 0;
        for(int i =1 ;i < num+1; i++){
            if(i % 3l == 0l && i % 5l == 0l){
            }else if(i % 3l == 0l){
            }else if(i % 5l == 0l){
            }else{
                count += i;
            }
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        long num = sc.nextLong();
        long count = 0;
        for(int i =1 ;i < num+1; i++){
            if(i % 3l == 0l && i % 5l == 0l){
            }else if(i % 3l == 0l){
            }else if(i % 5l == 0l){
            }else{
                count += i;
            }
        }
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long num = sc.nextLong(); num sc.nextLong() sc.nextLong sc long count = 0; count 0 for(int i =1 ;i < num+1; i++){
            if(i % 3l == 0l && i % 5l == 0l){
            }else if(i % 3l == 0l){
            }else if(i % 5l == 0l){
            }else{
                count += i;
            }
        } int i =1 ; int i =1 ; i 1 i < num+1 i num+1 num 1 i++ i++ i {
            if(i % 3l == 0l && i % 5l == 0l){
            }else if(i % 3l == 0l){
            }else if(i % 5l == 0l){
            }else{
                count += i;
            }
        } {
            if(i % 3l == 0l && i % 5l == 0l){
            }else if(i % 3l == 0l){
            }else if(i % 5l == 0l){
            }else{
                count += i;
            }
        } if(i % 3l == 0l && i % 5l == 0l){
            }else if(i % 3l == 0l){
            }else if(i % 5l == 0l){
            }else{
                count += i;
            } i % 3l == 0l && i % 5l == 0l i % 3l == 0l i % 3l i 3l 0l i % 5l == 0l i % 5l i 5l 0l {
            } if(i % 3l == 0l){
            }else if(i % 5l == 0l){
            }else{
                count += i;
            } i % 3l == 0l i % 3l i 3l 0l {
            } if(i % 5l == 0l){
            }else{
                count += i;
            } i % 5l == 0l i % 5l i 5l 0l {
            } {
                count += i;
            } count += i count i System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long num = sc.nextLong();
        long count = 0;
        for(int i =1 ;i < num+1; i++){
            if(i % 3l == 0l && i % 5l == 0l){
            }else if(i % 3l == 0l){
            }else if(i % 5l == 0l){
            }else{
                count += i;
            }
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long num = sc.nextLong();
        long count = 0;
        for(int i =1 ;i < num+1; i++){
            if(i % 3l == 0l && i % 5l == 0l){
            }else if(i % 3l == 0l){
            }else if(i % 5l == 0l){
            }else{
                count += i;
            }
        }
        System.out.println(count);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long num = sc.nextLong();
        long count = 0;
        for(int i =1 ;i < num+1; i++){
            if(i % 3l == 0l && i % 5l == 0l){
            }else if(i % 3l == 0l){
            }else if(i % 5l == 0l){
            }else{
                count += i;
            }
        }
        System.out.println(count);
    }
}