import java.util.Scanner;
import java.util.Arrays;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N=sc.nextLong();
    long Sum=0;
    long x=1;
      for(long i =1 ; i <=N; i++){
        if(!(x%3==0)&&!(x%5==0)){
          Sum+=x;
        }
        x++;
      }



        System.out.println(Sum);

        }
      } import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N=sc.nextLong();
    long Sum=0;
    long x=1;
      for(long i =1 ; i <=N; i++){
        if(!(x%3==0)&&!(x%5==0)){
          Sum+=x;
        }
        x++;
      }



        System.out.println(Sum);

        }
      } Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N=sc.nextLong();
    long Sum=0;
    long x=1;
      for(long i =1 ; i <=N; i++){
        if(!(x%3==0)&&!(x%5==0)){
          Sum+=x;
        }
        x++;
      }



        System.out.println(Sum);

        } main {
    Scanner sc = new Scanner(System.in);
    long N=sc.nextLong();
    long Sum=0;
    long x=1;
      for(long i =1 ; i <=N; i++){
        if(!(x%3==0)&&!(x%5==0)){
          Sum+=x;
        }
        x++;
      }



        System.out.println(Sum);

        } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long N=sc.nextLong(); N sc.nextLong() sc.nextLong sc long Sum=0; Sum 0 long x=1; x 1 for(long i =1 ; i <=N; i++){
        if(!(x%3==0)&&!(x%5==0)){
          Sum+=x;
        }
        x++;
      } long i =1 ; long i =1 ; i 1 i <=N i N i++ i++ i {
        if(!(x%3==0)&&!(x%5==0)){
          Sum+=x;
        }
        x++;
      } {
        if(!(x%3==0)&&!(x%5==0)){
          Sum+=x;
        }
        x++;
      } if(!(x%3==0)&&!(x%5==0)){
          Sum+=x;
        } !(x%3==0)&&!(x%5==0) !(x%3==0) (x%3==0) x%3 x 3 0 !(x%5==0) (x%5==0) x%5 x 5 0 {
          Sum+=x;
        } Sum+=x Sum x x++ x System.out.println(Sum) System.out.println System.out System System.out Sum String[] args args
import java.util.Scanner;
import java.util.Arrays;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N=sc.nextLong();
    long Sum=0;
    long x=1;
      for(long i =1 ; i <=N; i++){
        if(!(x%3==0)&&!(x%5==0)){
          Sum+=x;
        }
        x++;
      }



        System.out.println(Sum);

        }
      }
