import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long answer = 0;
    long n = sc.nextLong();
    long i = 0;
    while(i < n){
      i++;
      if(i % 3 == 0 || i % 5 == 0) continue;
      answer += i;
    }
    System.out.println(answer);
  }
} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long answer = 0;
    long n = sc.nextLong();
    long i = 0;
    while(i < n){
      i++;
      if(i % 3 == 0 || i % 5 == 0) continue;
      answer += i;
    }
    System.out.println(answer);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long answer = 0;
    long n = sc.nextLong();
    long i = 0;
    while(i < n){
      i++;
      if(i % 3 == 0 || i % 5 == 0) continue;
      answer += i;
    }
    System.out.println(answer);
  } main {
    Scanner sc = new Scanner(System.in);
    long answer = 0;
    long n = sc.nextLong();
    long i = 0;
    while(i < n){
      i++;
      if(i % 3 == 0 || i % 5 == 0) continue;
      answer += i;
    }
    System.out.println(answer);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long answer = 0; answer 0 long n = sc.nextLong(); n sc.nextLong() sc.nextLong sc long i = 0; i 0 while(i < n){
      i++;
      if(i % 3 == 0 || i % 5 == 0) continue;
      answer += i;
    } i < n i n {
      i++;
      if(i % 3 == 0 || i % 5 == 0) continue;
      answer += i;
    } i++ i if(i % 3 == 0 || i % 5 == 0) continue; i % 3 == 0 || i % 5 == 0 i % 3 == 0 i % 3 i 3 0 i % 5 == 0 i % 5 i 5 0 continue; answer += i answer i System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long answer = 0;
    long n = sc.nextLong();
    long i = 0;
    while(i < n){
      i++;
      if(i % 3 == 0 || i % 5 == 0) continue;
      answer += i;
    }
    System.out.println(answer);
  }
} public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long answer = 0;
    long n = sc.nextLong();
    long i = 0;
    while(i < n){
      i++;
      if(i % 3 == 0 || i % 5 == 0) continue;
      answer += i;
    }
    System.out.println(answer);
  }
} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long answer = 0;
    long n = sc.nextLong();
    long i = 0;
    while(i < n){
      i++;
      if(i % 3 == 0 || i % 5 == 0) continue;
      answer += i;
    }
    System.out.println(answer);
  }
}