import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		long r = solve(n);
		System.out.println(r);
		in.close();
	}

	private static long solve(int n) {
		long r = 0;
		for (int i = 1; i <= n; i++)
			if (i % 3 == 0 || i % 5 == 0)
				continue;
			else
				r += i;
		return r;
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		long r = solve(n);
		System.out.println(r);
		in.close();
	}

	private static long solve(int n) {
		long r = 0;
		for (int i = 1; i <= n; i++)
			if (i % 3 == 0 || i % 5 == 0)
				continue;
			else
				r += i;
		return r;
	}

} Main public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		long r = solve(n);
		System.out.println(r);
		in.close();
	} main {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		long r = solve(n);
		System.out.println(r);
		in.close();
	} Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); in new Scanner(new BufferedReader(new InputStreamReader(System.in))) int n = in.nextInt(); n in.nextInt() in.nextInt in long r = solve(n); r solve(n) solve n System.out.println(r) System.out.println System.out System System.out r in.close() in.close in String[] args args private static long solve(int n) {
		long r = 0;
		for (int i = 1; i <= n; i++)
			if (i % 3 == 0 || i % 5 == 0)
				continue;
			else
				r += i;
		return r;
	} solve {
		long r = 0;
		for (int i = 1; i <= n; i++)
			if (i % 3 == 0 || i % 5 == 0)
				continue;
			else
				r += i;
		return r;
	} long r = 0; r 0 for (int i = 1; i <= n; i++)
			if (i % 3 == 0 || i % 5 == 0)
				continue;
			else
				r += 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
				r += i; if (i % 3 == 0 || i % 5 == 0)
				continue;
			else
				r += i; i % 3 == 0 || i % 5 == 0 i % 3 == 0 i % 3 i 3 0 i % 5 == 0 i % 5 i 5 0 continue; r += i r i return r; r int n n public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		long r = solve(n);
		System.out.println(r);
		in.close();
	}

	private static long solve(int n) {
		long r = 0;
		for (int i = 1; i <= n; i++)
			if (i % 3 == 0 || i % 5 == 0)
				continue;
			else
				r += i;
		return r;
	}

} public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		long r = solve(n);
		System.out.println(r);
		in.close();
	}

	private static long solve(int n) {
		long r = 0;
		for (int i = 1; i <= n; i++)
			if (i % 3 == 0 || i % 5 == 0)
				continue;
			else
				r += i;
		return r;
	}

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		long r = solve(n);
		System.out.println(r);
		in.close();
	}

	private static long solve(int n) {
		long r = 0;
		for (int i = 1; i <= n; i++)
			if (i % 3 == 0 || i % 5 == 0)
				continue;
			else
				r += i;
		return r;
	}

}