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