import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    long N = scan.nextInt();
    long total = 0;
    
    for(int i = 0; N != i; N--){
      if(N%3 != 0&&N%5 != 0){
        total += N;
      }
    }
    System.out.print(total);
    }
  }



 import java.util.Scanner; Scanner java.util public class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    long N = scan.nextInt();
    long total = 0;
    
    for(int i = 0; N != i; N--){
      if(N%3 != 0&&N%5 != 0){
        total += N;
      }
    }
    System.out.print(total);
    }
  } Main public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    long N = scan.nextInt();
    long total = 0;
    
    for(int i = 0; N != i; N--){
      if(N%3 != 0&&N%5 != 0){
        total += N;
      }
    }
    System.out.print(total);
    } main {
    Scanner scan = new Scanner(System.in);
    long N = scan.nextInt();
    long total = 0;
    
    for(int i = 0; N != i; N--){
      if(N%3 != 0&&N%5 != 0){
        total += N;
      }
    }
    System.out.print(total);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long N = scan.nextInt(); N scan.nextInt() scan.nextInt scan long total = 0; total 0 for(int i = 0; N != i; N--){
      if(N%3 != 0&&N%5 != 0){
        total += N;
      }
    } int i = 0; int i = 0; i 0 N != i N i N-- N-- N {
      if(N%3 != 0&&N%5 != 0){
        total += N;
      }
    } {
      if(N%3 != 0&&N%5 != 0){
        total += N;
      }
    } if(N%3 != 0&&N%5 != 0){
        total += N;
      } N%3 != 0&&N%5 != 0 N%3 != 0 N%3 N 3 0 N%5 != 0 N%5 N 5 0 {
        total += N;
      } total += N total N System.out.print(total) System.out.print System.out System System.out total String args[] args public class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    long N = scan.nextInt();
    long total = 0;
    
    for(int i = 0; N != i; N--){
      if(N%3 != 0&&N%5 != 0){
        total += N;
      }
    }
    System.out.print(total);
    }
  } public class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    long N = scan.nextInt();
    long total = 0;
    
    for(int i = 0; N != i; N--){
      if(N%3 != 0&&N%5 != 0){
        total += N;
      }
    }
    System.out.print(total);
    }
  } Main
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    long N = scan.nextInt();
    long total = 0;
    
    for(int i = 0; N != i; N--){
      if(N%3 != 0&&N%5 != 0){
        total += N;
      }
    }
    System.out.print(total);
    }
  }




