import java.util.*;
public class Main{
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long N = n;
    long m = 0 ;
    for(long i=1;i<N+1;i++){
    if ((i%3)==0){}
    else if ((i%5)==0){}
    else{
    m = m+i;
    }
    }
	System.out.println(m);
    }   
} import java.util.*; util.* java public class Main{
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long N = n;
    long m = 0 ;
    for(long i=1;i<N+1;i++){
    if ((i%3)==0){}
    else if ((i%5)==0){}
    else{
    m = m+i;
    }
    }
	System.out.println(m);
    }   
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long N = n;
    long m = 0 ;
    for(long i=1;i<N+1;i++){
    if ((i%3)==0){}
    else if ((i%5)==0){}
    else{
    m = m+i;
    }
    }
	System.out.println(m);
    } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long N = n;
    long m = 0 ;
    for(long i=1;i<N+1;i++){
    if ((i%3)==0){}
    else if ((i%5)==0){}
    else{
    m = m+i;
    }
    }
	System.out.println(m);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long N = n; N n long m = 0 ; m 0 for(long i=1;i<N+1;i++){
    if ((i%3)==0){}
    else if ((i%5)==0){}
    else{
    m = m+i;
    }
    } long i=1; long i=1; i 1 i<N+1 i N+1 N 1 i++ i++ i {
    if ((i%3)==0){}
    else if ((i%5)==0){}
    else{
    m = m+i;
    }
    } {
    if ((i%3)==0){}
    else if ((i%5)==0){}
    else{
    m = m+i;
    }
    } if ((i%3)==0){}
    else if ((i%5)==0){}
    else{
    m = m+i;
    } (i%3)==0 (i%3) i 3 0 {} if ((i%5)==0){}
    else{
    m = m+i;
    } (i%5)==0 (i%5) i 5 0 {} {
    m = m+i;
    } m = m+i m m+i m i System.out.println(m) System.out.println System.out System System.out m String[] args args public class Main{
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long N = n;
    long m = 0 ;
    for(long i=1;i<N+1;i++){
    if ((i%3)==0){}
    else if ((i%5)==0){}
    else{
    m = m+i;
    }
    }
	System.out.println(m);
    }   
} public class Main{
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long N = n;
    long m = 0 ;
    for(long i=1;i<N+1;i++){
    if ((i%3)==0){}
    else if ((i%5)==0){}
    else{
    m = m+i;
    }
    }
	System.out.println(m);
    }   
} Main
import java.util.*;
public class Main{
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long N = n;
    long m = 0 ;
    for(long i=1;i<N+1;i++){
    if ((i%3)==0){}
    else if ((i%5)==0){}
    else{
    m = m+i;
    }
    }
	System.out.println(m);
    }   
}
