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