import java.util.*;

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

class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long out = 0;
        for(int i = 1; i <= n; i++){
            if(i % 3 != 0 && i % 5 != 0) out += i;
        }
        System.out.println(out);
        scan.close();
    }
    public static void main(String[] args){
        new Main().solve();
    }
}
