import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(reader.readLine());
        long count=0;
        for (int i = 1; i <=n ; i++) {
            if(i%3==0 || i%5==0)
                continue;
            else
                count+=i;
        }
        System.out.println(count);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(reader.readLine());
        long count=0;
        for (int i = 1; i <=n ; i++) {
            if(i%3==0 || i%5==0)
                continue;
            else
                count+=i;
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(reader.readLine());
        long count=0;
        for (int i = 1; i <=n ; i++) {
            if(i%3==0 || i%5==0)
                continue;
            else
                count+=i;
        }
        System.out.println(count);
    } main {
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(reader.readLine());
        long count=0;
        for (int i = 1; i <=n ; i++) {
            if(i%3==0 || i%5==0)
                continue;
            else
                count+=i;
        }
        System.out.println(count);
    } BufferedReader reader=new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) int n=Integer.parseInt(reader.readLine()); n Integer.parseInt(reader.readLine()) Integer.parseInt Integer reader.readLine() reader.readLine reader long count=0; count 0 for (int i = 1; i <=n ; i++) {
            if(i%3==0 || i%5==0)
                continue;
            else
                count+=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
                count+=i;
        } {
            if(i%3==0 || i%5==0)
                continue;
            else
                count+=i;
        } if(i%3==0 || i%5==0)
                continue;
            else
                count+=i; i%3==0 || i%5==0 i%3==0 i%3 i 3 0 i%5==0 i%5 i 5 0 continue; 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) throws IOException {
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(reader.readLine());
        long count=0;
        for (int i = 1; i <=n ; i++) {
            if(i%3==0 || i%5==0)
                continue;
            else
                count+=i;
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(reader.readLine());
        long count=0;
        for (int i = 1; i <=n ; i++) {
            if(i%3==0 || i%5==0)
                continue;
            else
                count+=i;
        }
        System.out.println(count);
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(reader.readLine());
        long count=0;
        for (int i = 1; i <=n ; i++) {
            if(i%3==0 || i%5==0)
                continue;
            else
                count+=i;
        }
        System.out.println(count);
    }
}