import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		long num = 0;

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

		System.out.println(num);
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		long num = 0;

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

		System.out.println(num);
	}

} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		long num = 0;

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

		System.out.println(num);
	} main {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		long num = 0;

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

		System.out.println(num);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan long num = 0; num 0 for(int i = 1; i < N+1; i++) {
			if (i % 3 != 0 && i % 5 != 0) {
				num += i;
			}
		} int i = 1; int i = 1; i 1 i < N+1 i N+1 N 1 i++ i++ i {
			if (i % 3 != 0 && i % 5 != 0) {
				num += i;
			}
		} {
			if (i % 3 != 0 && i % 5 != 0) {
				num += i;
			}
		} if (i % 3 != 0 && i % 5 != 0) {
				num += i;
			} i % 3 != 0 && i % 5 != 0 i % 3 != 0 i % 3 i 3 0 i % 5 != 0 i % 5 i 5 0 {
				num += i;
			} num += i num i System.out.println(num) System.out.println System.out System System.out num String[] args args public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		long num = 0;

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

		System.out.println(num);
	}

} public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		long num = 0;

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

		System.out.println(num);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		long num = 0;

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

		System.out.println(num);
	}

}