import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner a= new Scanner(System.in);
    int j = a.nextInt();
    long ans = 0;
    for(int i = 1; i <= j; i++){
      if(i%3==0 || i%5 == 0)
        continue;
      else
        ans+=i;
    }
    System.out.println(ans);
  }
} import java.util.Scanner; Scanner java.util public class Main{
  public static void main(String[] args){
    Scanner a= new Scanner(System.in);
    int j = a.nextInt();
    long ans = 0;
    for(int i = 1; i <= j; i++){
      if(i%3==0 || i%5 == 0)
        continue;
      else
        ans+=i;
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args){
    Scanner a= new Scanner(System.in);
    int j = a.nextInt();
    long ans = 0;
    for(int i = 1; i <= j; i++){
      if(i%3==0 || i%5 == 0)
        continue;
      else
        ans+=i;
    }
    System.out.println(ans);
  } main {
    Scanner a= new Scanner(System.in);
    int j = a.nextInt();
    long ans = 0;
    for(int i = 1; i <= j; i++){
      if(i%3==0 || i%5 == 0)
        continue;
      else
        ans+=i;
    }
    System.out.println(ans);
  } Scanner a= new Scanner(System.in); a new Scanner(System.in) int j = a.nextInt(); j a.nextInt() a.nextInt a long ans = 0; ans 0 for(int i = 1; i <= j; i++){
      if(i%3==0 || i%5 == 0)
        continue;
      else
        ans+=i;
    } int i = 1; int i = 1; i 1 i <= j i j i++ i++ i {
      if(i%3==0 || i%5 == 0)
        continue;
      else
        ans+=i;
    } {
      if(i%3==0 || i%5 == 0)
        continue;
      else
        ans+=i;
    } if(i%3==0 || i%5 == 0)
        continue;
      else
        ans+=i; i%3==0 || i%5 == 0 i%3==0 i%3 i 3 0 i%5 == 0 i%5 i 5 0 continue; 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){
    Scanner a= new Scanner(System.in);
    int j = a.nextInt();
    long ans = 0;
    for(int i = 1; i <= j; i++){
      if(i%3==0 || i%5 == 0)
        continue;
      else
        ans+=i;
    }
    System.out.println(ans);
  }
} public class Main{
  public static void main(String[] args){
    Scanner a= new Scanner(System.in);
    int j = a.nextInt();
    long ans = 0;
    for(int i = 1; i <= j; i++){
      if(i%3==0 || i%5 == 0)
        continue;
      else
        ans+=i;
    }
    System.out.println(ans);
  }
} Main
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner a= new Scanner(System.in);
    int j = a.nextInt();
    long ans = 0;
    for(int i = 1; i <= j; i++){
      if(i%3==0 || i%5 == 0)
        continue;
      else
        ans+=i;
    }
    System.out.println(ans);
  }
}