import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] sum = new long[n+1];
		sum[1] = 1;
		for (int i = 2; i < n+1; i++) {
			if (i % 3== 0 || i%5 ==0) {
				sum[i] = sum[i-1];
			} else {
				sum[i] = sum[i-1] + i;
			}
		}
		System.out.println(sum[n]);
	}

} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] sum = new long[n+1];
		sum[1] = 1;
		for (int i = 2; i < n+1; i++) {
			if (i % 3== 0 || i%5 ==0) {
				sum[i] = sum[i-1];
			} else {
				sum[i] = sum[i-1] + i;
			}
		}
		System.out.println(sum[n]);
	}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] sum = new long[n+1];
		sum[1] = 1;
		for (int i = 2; i < n+1; i++) {
			if (i % 3== 0 || i%5 ==0) {
				sum[i] = sum[i-1];
			} else {
				sum[i] = sum[i-1] + i;
			}
		}
		System.out.println(sum[n]);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] sum = new long[n+1];
		sum[1] = 1;
		for (int i = 2; i < n+1; i++) {
			if (i % 3== 0 || i%5 ==0) {
				sum[i] = sum[i-1];
			} else {
				sum[i] = sum[i-1] + i;
			}
		}
		System.out.println(sum[n]);
	}

} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] sum = new long[n+1];
		sum[1] = 1;
		for (int i = 2; i < n+1; i++) {
			if (i % 3== 0 || i%5 ==0) {
				sum[i] = sum[i-1];
			} else {
				sum[i] = sum[i-1] + i;
			}
		}
		System.out.println(sum[n]);
	}

}
