
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		long sum = 0L;
		for (int i = 1; i <= N; ++i) {
			if ((i % 3 != 0) && (i % 5 != 0)) {
				sum += i;
			}
		}
		System.out.println(sum);
	}

	void calc() {
	}

	void showResult() {
	}
} import java.util.*; util.* java import java.util.stream.Collectors; Collectors java.util.stream import java.io.*; io.* java import java.nio.charset.StandardCharsets; StandardCharsets java.nio.charset public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		long sum = 0L;
		for (int i = 1; i <= N; ++i) {
			if ((i % 3 != 0) && (i % 5 != 0)) {
				sum += i;
			}
		}
		System.out.println(sum);
	}

	void calc() {
	}

	void showResult() {
	}
} Main public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	} main {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	} InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8); reader new InputStreamReader(System.in, StandardCharsets.UTF_8) BufferedReader in = new BufferedReader(reader); in new BufferedReader(reader) Main ins = new Main(in); ins new Main(in) ins.calc() ins.calc ins ins.showResult() ins.showResult ins String[] args args Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		long sum = 0L;
		for (int i = 1; i <= N; ++i) {
			if ((i % 3 != 0) && (i % 5 != 0)) {
				sum += i;
			}
		}
		System.out.println(sum);
	} Main {
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		long sum = 0L;
		for (int i = 1; i <= N; ++i) {
			if ((i % 3 != 0) && (i % 5 != 0)) {
				sum += i;
			}
		}
		System.out.println(sum);
	} String[] tokens = in.readLine().split(" "); tokens in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " int N = Integer.parseInt(tokens[0]); N Integer.parseInt(tokens[0]) Integer.parseInt Integer tokens[0] tokens 0 long sum = 0L; sum 0L for (int i = 1; i <= N; ++i) {
			if ((i % 3 != 0) && (i % 5 != 0)) {
				sum += i;
			}
		} int i = 1; int i = 1; i 1 i <= N i N ++i ++i i {
			if ((i % 3 != 0) && (i % 5 != 0)) {
				sum += i;
			}
		} {
			if ((i % 3 != 0) && (i % 5 != 0)) {
				sum += i;
			}
		} if ((i % 3 != 0) && (i % 5 != 0)) {
				sum += i;
			} (i % 3 != 0) && (i % 5 != 0) (i % 3 != 0) i % 3 i 3 0 (i % 5 != 0) i % 5 i 5 0 {
				sum += i;
			} sum += i sum i System.out.println(sum) System.out.println System.out System System.out sum BufferedReader in in void calc() {
	} calc {
	} void showResult() {
	} showResult {
	} public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		long sum = 0L;
		for (int i = 1; i <= N; ++i) {
			if ((i % 3 != 0) && (i % 5 != 0)) {
				sum += i;
			}
		}
		System.out.println(sum);
	}

	void calc() {
	}

	void showResult() {
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		long sum = 0L;
		for (int i = 1; i <= N; ++i) {
			if ((i % 3 != 0) && (i % 5 != 0)) {
				sum += i;
			}
		}
		System.out.println(sum);
	}

	void calc() {
	}

	void showResult() {
	}
} Main

import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		long sum = 0L;
		for (int i = 1; i <= N; ++i) {
			if ((i % 3 != 0) && (i % 5 != 0)) {
				sum += i;
			}
		}
		System.out.println(sum);
	}

	void calc() {
	}

	void showResult() {
	}
}
