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