import java.util.Scanner;

public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値
		int N = scan.nextInt();

		//WK変数
		long sum = 0L;

		//演算
		for (int i = 1; i <= N; i++) {
			if (i % 3 != 0 && i % 5 != 0) {
				sum += i;
			}
		}

		//結果出力
		System.out.println(sum);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値
		int N = scan.nextInt();

		//WK変数
		long sum = 0L;

		//演算
		for (int i = 1; i <= N; i++) {
			if (i % 3 != 0 && i % 5 != 0) {
				sum += i;
			}
		}

		//結果出力
		System.out.println(sum);
	}
} Main static Main instance = new Main(); instance new Main() public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値
		int N = scan.nextInt();

		//WK変数
		long sum = 0L;

		//演算
		for (int i = 1; i <= N; i++) {
			if (i % 3 != 0 && i % 5 != 0) {
				sum += i;
			}
		}

		//結果出力
		System.out.println(sum);
	} main {

		Scanner scan = new Scanner(System.in);

		//入力値
		int N = scan.nextInt();

		//WK変数
		long sum = 0L;

		//演算
		for (int i = 1; i <= N; i++) {
			if (i % 3 != 0 && i % 5 != 0) {
				sum += i;
			}
		}

		//結果出力
		System.out.println(sum);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan 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 String[] args args public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値
		int N = scan.nextInt();

		//WK変数
		long sum = 0L;

		//演算
		for (int i = 1; i <= N; i++) {
			if (i % 3 != 0 && i % 5 != 0) {
				sum += i;
			}
		}

		//結果出力
		System.out.println(sum);
	}
} public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値
		int N = scan.nextInt();

		//WK変数
		long sum = 0L;

		//演算
		for (int i = 1; i <= N; i++) {
			if (i % 3 != 0 && i % 5 != 0) {
				sum += i;
			}
		}

		//結果出力
		System.out.println(sum);
	}
} Main
import java.util.Scanner;

public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値
		int N = scan.nextInt();

		//WK変数
		long sum = 0L;

		//演算
		for (int i = 1; i <= N; i++) {
			if (i % 3 != 0 && i % 5 != 0) {
				sum += i;
			}
		}

		//結果出力
		System.out.println(sum);
	}
}