import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      long N = Long.parseLong(br.readLine());
      long ans = 0;
      for(long i = 1; i <= N; i++){
        if(i%3 != 0 && i%5 != 0){
          ans += i;
        }
      }
      System.out.println(ans);
    }catch(Exception e){
    }
  }
} import java.util.*; util.* java import java.io.*; io.* java public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      long N = Long.parseLong(br.readLine());
      long ans = 0;
      for(long i = 1; i <= N; i++){
        if(i%3 != 0 && i%5 != 0){
          ans += i;
        }
      }
      System.out.println(ans);
    }catch(Exception e){
    }
  }
} Main public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      long N = Long.parseLong(br.readLine());
      long ans = 0;
      for(long i = 1; i <= N; i++){
        if(i%3 != 0 && i%5 != 0){
          ans += i;
        }
      }
      System.out.println(ans);
    }catch(Exception e){
    }
  } main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      long N = Long.parseLong(br.readLine());
      long ans = 0;
      for(long i = 1; i <= N; i++){
        if(i%3 != 0 && i%5 != 0){
          ans += i;
        }
      }
      System.out.println(ans);
    }catch(Exception e){
    }
  } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) try{
      long N = Long.parseLong(br.readLine());
      long ans = 0;
      for(long i = 1; i <= N; i++){
        if(i%3 != 0 && i%5 != 0){
          ans += i;
        }
      }
      System.out.println(ans);
    }catch(Exception e){
    } catch(Exception e){
    } Exception e {
    } {
      long N = Long.parseLong(br.readLine());
      long ans = 0;
      for(long i = 1; i <= N; i++){
        if(i%3 != 0 && i%5 != 0){
          ans += i;
        }
      }
      System.out.println(ans);
    } long N = Long.parseLong(br.readLine()); N Long.parseLong(br.readLine()) Long.parseLong Long br.readLine() br.readLine br long ans = 0; ans 0 for(long i = 1; i <= N; i++){
        if(i%3 != 0 && i%5 != 0){
          ans += i;
        }
      } long i = 1; long i = 1; i 1 i <= N i N i++ i++ i {
        if(i%3 != 0 && i%5 != 0){
          ans += i;
        }
      } {
        if(i%3 != 0 && i%5 != 0){
          ans += i;
        }
      } if(i%3 != 0 && i%5 != 0){
          ans += i;
        } i%3 != 0 && i%5 != 0 i%3 != 0 i%3 i 3 0 i%5 != 0 i%5 i 5 0 {
          ans += i;
        } ans += i ans i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      long N = Long.parseLong(br.readLine());
      long ans = 0;
      for(long i = 1; i <= N; i++){
        if(i%3 != 0 && i%5 != 0){
          ans += i;
        }
      }
      System.out.println(ans);
    }catch(Exception e){
    }
  }
} public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      long N = Long.parseLong(br.readLine());
      long ans = 0;
      for(long i = 1; i <= N; i++){
        if(i%3 != 0 && i%5 != 0){
          ans += i;
        }
      }
      System.out.println(ans);
    }catch(Exception e){
    }
  }
} Main
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      long N = Long.parseLong(br.readLine());
      long ans = 0;
      for(long i = 1; i <= N; i++){
        if(i%3 != 0 && i%5 != 0){
          ans += i;
        }
      }
      System.out.println(ans);
    }catch(Exception e){
    }
  }
}