import java.io.*;

class Main
{
    public static void main(String args[])
    {
        String buf;
        int num;
        long ans;
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            buf = br.readLine();
            num = Integer.parseInt(buf);
            ans = 0;
            for(int i = 1; i <= num; i++){
                if (i % 3 == 0 || i % 5 == 0){
                    continue;
                }else{
                    ans += i;
                }
            }
            System.out.println(Long.toString(ans));
        } catch(Exception e) {}
  }
} import java.io.*; io.* java class Main
{
    public static void main(String args[])
    {
        String buf;
        int num;
        long ans;
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            buf = br.readLine();
            num = Integer.parseInt(buf);
            ans = 0;
            for(int i = 1; i <= num; i++){
                if (i % 3 == 0 || i % 5 == 0){
                    continue;
                }else{
                    ans += i;
                }
            }
            System.out.println(Long.toString(ans));
        } catch(Exception e) {}
  }
} Main public static void main(String args[])
    {
        String buf;
        int num;
        long ans;
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            buf = br.readLine();
            num = Integer.parseInt(buf);
            ans = 0;
            for(int i = 1; i <= num; i++){
                if (i % 3 == 0 || i % 5 == 0){
                    continue;
                }else{
                    ans += i;
                }
            }
            System.out.println(Long.toString(ans));
        } catch(Exception e) {}
  } main {
        String buf;
        int num;
        long ans;
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            buf = br.readLine();
            num = Integer.parseInt(buf);
            ans = 0;
            for(int i = 1; i <= num; i++){
                if (i % 3 == 0 || i % 5 == 0){
                    continue;
                }else{
                    ans += i;
                }
            }
            System.out.println(Long.toString(ans));
        } catch(Exception e) {}
  } String buf; buf int num; num long ans; ans try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            buf = br.readLine();
            num = Integer.parseInt(buf);
            ans = 0;
            for(int i = 1; i <= num; i++){
                if (i % 3 == 0 || i % 5 == 0){
                    continue;
                }else{
                    ans += i;
                }
            }
            System.out.println(Long.toString(ans));
        } catch(Exception e) {} catch(Exception e) {} Exception e {} {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            buf = br.readLine();
            num = Integer.parseInt(buf);
            ans = 0;
            for(int i = 1; i <= num; i++){
                if (i % 3 == 0 || i % 5 == 0){
                    continue;
                }else{
                    ans += i;
                }
            }
            System.out.println(Long.toString(ans));
        } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) buf = br.readLine() buf br.readLine() br.readLine br num = Integer.parseInt(buf) num Integer.parseInt(buf) Integer.parseInt Integer buf ans = 0 ans 0 for(int i = 1; i <= num; i++){
                if (i % 3 == 0 || i % 5 == 0){
                    continue;
                }else{
                    ans += i;
                }
            } int i = 1; int i = 1; i 1 i <= num i num i++ i++ i {
                if (i % 3 == 0 || i % 5 == 0){
                    continue;
                }else{
                    ans += i;
                }
            } {
                if (i % 3 == 0 || i % 5 == 0){
                    continue;
                }else{
                    ans += i;
                }
            } if (i % 3 == 0 || i % 5 == 0){
                    continue;
                }else{
                    ans += 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; {
                    ans += i;
                } ans += i ans i System.out.println(Long.toString(ans)) System.out.println System.out System System.out Long.toString(ans) Long.toString Long ans String args[] args
import java.io.*;

class Main
{
    public static void main(String args[])
    {
        String buf;
        int num;
        long ans;
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            buf = br.readLine();
            num = Integer.parseInt(buf);
            ans = 0;
            for(int i = 1; i <= num; i++){
                if (i % 3 == 0 || i % 5 == 0){
                    continue;
                }else{
                    ans += i;
                }
            }
            System.out.println(Long.toString(ans));
        } catch(Exception e) {}
  }
}