import java.util.*;

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long count = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 3 == 0 || i % 5 == 0)
                continue;
            else
                count += i;
        }
        System.out.println(count);
    }
}