import java.util.Arrays;
import java.util.Scanner;
public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        long n;
        n = nextLong();
        Long sum = 0L;
        for(long i = 1;i<=n;i++){
            if(i%3!=0&&i%5!=0&&i%15!=0){
                sum+=i;
            }
        }
        print(sum);
    }



    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
    public static void print(Object a){
        System.out.println(a);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        long n;
        n = nextLong();
        Long sum = 0L;
        for(long i = 1;i<=n;i++){
            if(i%3!=0&&i%5!=0&&i%15!=0){
                sum+=i;
            }
        }
        print(sum);
    }



    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
    public static void print(Object a){
        System.out.println(a);
    }
} Main public static Scanner scan  = new Scanner(System.in); scan new Scanner(System.in) public static void main(String[]args){
        long n;
        n = nextLong();
        Long sum = 0L;
        for(long i = 1;i<=n;i++){
            if(i%3!=0&&i%5!=0&&i%15!=0){
                sum+=i;
            }
        }
        print(sum);
    } main {
        long n;
        n = nextLong();
        Long sum = 0L;
        for(long i = 1;i<=n;i++){
            if(i%3!=0&&i%5!=0&&i%15!=0){
                sum+=i;
            }
        }
        print(sum);
    } long n; n n = nextLong() n nextLong() nextLong Long sum = 0L; sum 0L for(long i = 1;i<=n;i++){
            if(i%3!=0&&i%5!=0&&i%15!=0){
                sum+=i;
            }
        } long i = 1; long i = 1; i 1 i<=n i n i++ i++ i {
            if(i%3!=0&&i%5!=0&&i%15!=0){
                sum+=i;
            }
        } {
            if(i%3!=0&&i%5!=0&&i%15!=0){
                sum+=i;
            }
        } if(i%3!=0&&i%5!=0&&i%15!=0){
                sum+=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 {
                sum+=i;
            } sum+=i sum i print(sum) print sum String[]args args public static int nextInt(){
        return Integer.parseInt(scan.next());
    } nextInt {
        return Integer.parseInt(scan.next());
    } return Integer.parseInt(scan.next()); Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan public static long nextLong(){
        return Long.parseLong(scan.next());
    } nextLong {
        return Long.parseLong(scan.next());
    } return Long.parseLong(scan.next()); Long.parseLong(scan.next()) Long.parseLong Long scan.next() scan.next scan public static String next(){
        return scan.next();
    } next {
        return scan.next();
    } return scan.next(); scan.next() scan.next scan public static double nextDouble(){
        return Double.parseDouble(scan.next());
    } nextDouble {
        return Double.parseDouble(scan.next());
    } return Double.parseDouble(scan.next()); Double.parseDouble(scan.next()) Double.parseDouble Double scan.next() scan.next scan public static float nextFloat(){
        return Float.parseFloat(scan.next());
    } nextFloat {
        return Float.parseFloat(scan.next());
    } return Float.parseFloat(scan.next()); Float.parseFloat(scan.next()) Float.parseFloat Float scan.next() scan.next scan //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    } yesNo {
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    } if(flag) System.out.println("Yes");
        else System.out.println("No"); flag System.out.println("Yes") System.out.println System.out System System.out "Yes" System.out.println("No") System.out.println System.out System System.out "No" boolean flag flag public static void print(Object a){
        System.out.println(a);
    } print {
        System.out.println(a);
    } System.out.println(a) System.out.println System.out System System.out a Object a a public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        long n;
        n = nextLong();
        Long sum = 0L;
        for(long i = 1;i<=n;i++){
            if(i%3!=0&&i%5!=0&&i%15!=0){
                sum+=i;
            }
        }
        print(sum);
    }



    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
    public static void print(Object a){
        System.out.println(a);
    }
} public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        long n;
        n = nextLong();
        Long sum = 0L;
        for(long i = 1;i<=n;i++){
            if(i%3!=0&&i%5!=0&&i%15!=0){
                sum+=i;
            }
        }
        print(sum);
    }



    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
    public static void print(Object a){
        System.out.println(a);
    }
} Main
import java.util.Arrays;
import java.util.Scanner;
public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        long n;
        n = nextLong();
        Long sum = 0L;
        for(long i = 1;i<=n;i++){
            if(i%3!=0&&i%5!=0&&i%15!=0){
                sum+=i;
            }
        }
        print(sum);
    }



    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
    public static void print(Object a){
        System.out.println(a);
    }
}