import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// ------------------------------------------------

		int n = Integer.parseInt(sc.next());

		long ret = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 15 == 0) {

			} else if (i % 3 == 0) {

			} else if (i % 5 == 0) {

			} else {
				ret += i;
			}
		}
		out.println(ret);

		// ------------------------------------------------
		sc.close();
		out.flush();
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// ------------------------------------------------

		int n = Integer.parseInt(sc.next());

		long ret = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 15 == 0) {

			} else if (i % 3 == 0) {

			} else if (i % 5 == 0) {

			} else {
				ret += i;
			}
		}
		out.println(ret);

		// ------------------------------------------------
		sc.close();
		out.flush();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// ------------------------------------------------

		int n = Integer.parseInt(sc.next());

		long ret = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 15 == 0) {

			} else if (i % 3 == 0) {

			} else if (i % 5 == 0) {

			} else {
				ret += i;
			}
		}
		out.println(ret);

		// ------------------------------------------------
		sc.close();
		out.flush();
	} main {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// ------------------------------------------------

		int n = Integer.parseInt(sc.next());

		long ret = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 15 == 0) {

			} else if (i % 3 == 0) {

			} else if (i % 5 == 0) {

			} else {
				ret += i;
			}
		}
		out.println(ret);

		// ------------------------------------------------
		sc.close();
		out.flush();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc long ret = 0; ret 0 for (int i = 1; i <= n; i++) {
			if (i % 15 == 0) {

			} else if (i % 3 == 0) {

			} else if (i % 5 == 0) {

			} else {
				ret += i;
			}
		} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
			if (i % 15 == 0) {

			} else if (i % 3 == 0) {

			} else if (i % 5 == 0) {

			} else {
				ret += i;
			}
		} {
			if (i % 15 == 0) {

			} else if (i % 3 == 0) {

			} else if (i % 5 == 0) {

			} else {
				ret += i;
			}
		} if (i % 15 == 0) {

			} else if (i % 3 == 0) {

			} else if (i % 5 == 0) {

			} else {
				ret += i;
			} i % 15 == 0 i % 15 i 15 0 {

			} if (i % 3 == 0) {

			} else if (i % 5 == 0) {

			} else {
				ret += i;
			} i % 3 == 0 i % 3 i 3 0 {

			} if (i % 5 == 0) {

			} else {
				ret += i;
			} i % 5 == 0 i % 5 i 5 0 {

			} {
				ret += i;
			} ret += i ret i out.println(ret) out.println out ret sc.close() sc.close sc out.flush() out.flush out String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// ------------------------------------------------

		int n = Integer.parseInt(sc.next());

		long ret = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 15 == 0) {

			} else if (i % 3 == 0) {

			} else if (i % 5 == 0) {

			} else {
				ret += i;
			}
		}
		out.println(ret);

		// ------------------------------------------------
		sc.close();
		out.flush();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// ------------------------------------------------

		int n = Integer.parseInt(sc.next());

		long ret = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 15 == 0) {

			} else if (i % 3 == 0) {

			} else if (i % 5 == 0) {

			} else {
				ret += i;
			}
		}
		out.println(ret);

		// ------------------------------------------------
		sc.close();
		out.flush();
	}
} Main
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// ------------------------------------------------

		int n = Integer.parseInt(sc.next());

		long ret = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 15 == 0) {

			} else if (i % 3 == 0) {

			} else if (i % 5 == 0) {

			} else {
				ret += i;
			}
		}
		out.println(ret);

		// ------------------------------------------------
		sc.close();
		out.flush();
	}
}