import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long N = in.nextLong();
        long three = N / 3 * (N / 3 + 1) / 2 * 3;
        long five = N / 5 * (N / 5 + 1) / 2 * 5;
        long fifteen = N / 15 * (N / 15 + 1) / 2 * 15;
        long all = N * (N + 1) / 2;
        System.out.println(all - three - five + fifteen);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long N = in.nextLong();
        long three = N / 3 * (N / 3 + 1) / 2 * 3;
        long five = N / 5 * (N / 5 + 1) / 2 * 5;
        long fifteen = N / 15 * (N / 15 + 1) / 2 * 15;
        long all = N * (N + 1) / 2;
        System.out.println(all - three - five + fifteen);
    }
} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long N = in.nextLong();
        long three = N / 3 * (N / 3 + 1) / 2 * 3;
        long five = N / 5 * (N / 5 + 1) / 2 * 5;
        long fifteen = N / 15 * (N / 15 + 1) / 2 * 15;
        long all = N * (N + 1) / 2;
        System.out.println(all - three - five + fifteen);
    } main {
        Scanner in = new Scanner(System.in);
        long N = in.nextLong();
        long three = N / 3 * (N / 3 + 1) / 2 * 3;
        long five = N / 5 * (N / 5 + 1) / 2 * 5;
        long fifteen = N / 15 * (N / 15 + 1) / 2 * 15;
        long all = N * (N + 1) / 2;
        System.out.println(all - three - five + fifteen);
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) long N = in.nextLong(); N in.nextLong() in.nextLong in long three = N / 3 * (N / 3 + 1) / 2 * 3; three N / 3 * (N / 3 + 1) / 2 * 3 N / 3 * (N / 3 + 1) / 2 N / 3 * (N / 3 + 1) N / 3 N 3 (N / 3 + 1) N / 3 N 3 1 2 3 long five = N / 5 * (N / 5 + 1) / 2 * 5; five N / 5 * (N / 5 + 1) / 2 * 5 N / 5 * (N / 5 + 1) / 2 N / 5 * (N / 5 + 1) N / 5 N 5 (N / 5 + 1) N / 5 N 5 1 2 5 long fifteen = N / 15 * (N / 15 + 1) / 2 * 15; fifteen N / 15 * (N / 15 + 1) / 2 * 15 N / 15 * (N / 15 + 1) / 2 N / 15 * (N / 15 + 1) N / 15 N 15 (N / 15 + 1) N / 15 N 15 1 2 15 long all = N * (N + 1) / 2; all N * (N + 1) / 2 N * (N + 1) N (N + 1) N 1 2 System.out.println(all - three - five + fifteen) System.out.println System.out System System.out all - three - five + fifteen all - three - five all - three - five all three five fifteen String[] args args public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long N = in.nextLong();
        long three = N / 3 * (N / 3 + 1) / 2 * 3;
        long five = N / 5 * (N / 5 + 1) / 2 * 5;
        long fifteen = N / 15 * (N / 15 + 1) / 2 * 15;
        long all = N * (N + 1) / 2;
        System.out.println(all - three - five + fifteen);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long N = in.nextLong();
        long three = N / 3 * (N / 3 + 1) / 2 * 3;
        long five = N / 5 * (N / 5 + 1) / 2 * 5;
        long fifteen = N / 15 * (N / 15 + 1) / 2 * 15;
        long all = N * (N + 1) / 2;
        System.out.println(all - three - five + fifteen);
    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long N = in.nextLong();
        long three = N / 3 * (N / 3 + 1) / 2 * 3;
        long five = N / 5 * (N / 5 + 1) / 2 * 5;
        long fifteen = N / 15 * (N / 15 + 1) / 2 * 15;
        long all = N * (N + 1) / 2;
        System.out.println(all - three - five + fifteen);
    }
}