import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			final long N = scn.nextLong();

			long sum = 0;
			for (long l = 1; l <= N; l++) {
				if (l % 3 != 0 && l % 5 != 0) {
					sum += l;
				}
			}
			System.out.println(sum);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			final long N = scn.nextLong();

			long sum = 0;
			for (long l = 1; l <= N; l++) {
				if (l % 3 != 0 && l % 5 != 0) {
					sum += l;
				}
			}
			System.out.println(sum);
		}
	}
} Main public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			final long N = scn.nextLong();

			long sum = 0;
			for (long l = 1; l <= N; l++) {
				if (l % 3 != 0 && l % 5 != 0) {
					sum += l;
				}
			}
			System.out.println(sum);
		}
	} main {
		try (Scanner scn = new Scanner(System.in)) {
			final long N = scn.nextLong();

			long sum = 0;
			for (long l = 1; l <= N; l++) {
				if (l % 3 != 0 && l % 5 != 0) {
					sum += l;
				}
			}
			System.out.println(sum);
		}
	} try (Scanner scn = new Scanner(System.in)) {
			final long N = scn.nextLong();

			long sum = 0;
			for (long l = 1; l <= N; l++) {
				if (l % 3 != 0 && l % 5 != 0) {
					sum += l;
				}
			}
			System.out.println(sum);
		} {
			final long N = scn.nextLong();

			long sum = 0;
			for (long l = 1; l <= N; l++) {
				if (l % 3 != 0 && l % 5 != 0) {
					sum += l;
				}
			}
			System.out.println(sum);
		} Scanner scn = new Scanner(System.in) Scanner scn = new Scanner(System.in) new Scanner(System.in) final long N = scn.nextLong(); N scn.nextLong() scn.nextLong scn long sum = 0; sum 0 for (long l = 1; l <= N; l++) {
				if (l % 3 != 0 && l % 5 != 0) {
					sum += l;
				}
			} long l = 1; long l = 1; l 1 l <= N l N l++ l++ l {
				if (l % 3 != 0 && l % 5 != 0) {
					sum += l;
				}
			} {
				if (l % 3 != 0 && l % 5 != 0) {
					sum += l;
				}
			} if (l % 3 != 0 && l % 5 != 0) {
					sum += l;
				} l % 3 != 0 && l % 5 != 0 l % 3 != 0 l % 3 l 3 0 l % 5 != 0 l % 5 l 5 0 {
					sum += l;
				} sum += l sum l System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			final long N = scn.nextLong();

			long sum = 0;
			for (long l = 1; l <= N; l++) {
				if (l % 3 != 0 && l % 5 != 0) {
					sum += l;
				}
			}
			System.out.println(sum);
		}
	}
} public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			final long N = scn.nextLong();

			long sum = 0;
			for (long l = 1; l <= N; l++) {
				if (l % 3 != 0 && l % 5 != 0) {
					sum += l;
				}
			}
			System.out.println(sum);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			final long N = scn.nextLong();

			long sum = 0;
			for (long l = 1; l <= N; l++) {
				if (l % 3 != 0 && l % 5 != 0) {
					sum += l;
				}
			}
			System.out.println(sum);
		}
	}
}
