import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int i;
	String N = br.readLine();
	int Num = Integer.parseInt(N);
	long sum = 0;

	for (i = 1; i <= Num; i++ ) {
		if (i % 3 != 0 && i % 5 != 0) sum = sum + i;
	}

	System.out.println(sum);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io class Main {
	public static void main(String args[]) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int i;
	String N = br.readLine();
	int Num = Integer.parseInt(N);
	long sum = 0;

	for (i = 1; i <= Num; i++ ) {
		if (i % 3 != 0 && i % 5 != 0) sum = sum + i;
	}

	System.out.println(sum);
	}
} Main public static void main(String args[]) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int i;
	String N = br.readLine();
	int Num = Integer.parseInt(N);
	long sum = 0;

	for (i = 1; i <= Num; i++ ) {
		if (i % 3 != 0 && i % 5 != 0) sum = sum + i;
	}

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

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int i;
	String N = br.readLine();
	int Num = Integer.parseInt(N);
	long sum = 0;

	for (i = 1; i <= Num; i++ ) {
		if (i % 3 != 0 && i % 5 != 0) sum = sum + i;
	}

	System.out.println(sum);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int i; i String N = br.readLine(); N br.readLine() br.readLine br int Num = Integer.parseInt(N); Num Integer.parseInt(N) Integer.parseInt Integer N long sum = 0; sum 0 for (i = 1; i <= Num; i++ ) {
		if (i % 3 != 0 && i % 5 != 0) sum = sum + i;
	} i = 1; i = 1 i 1 i <= Num i Num i++ i++ i {
		if (i % 3 != 0 && i % 5 != 0) sum = sum + i;
	} {
		if (i % 3 != 0 && i % 5 != 0) sum = sum + i;
	} if (i % 3 != 0 && i % 5 != 0) sum = 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 = sum + i sum sum + i sum i System.out.println(sum) System.out.println System.out System System.out sum String args[] args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int i;
	String N = br.readLine();
	int Num = Integer.parseInt(N);
	long sum = 0;

	for (i = 1; i <= Num; i++ ) {
		if (i % 3 != 0 && i % 5 != 0) sum = sum + i;
	}

	System.out.println(sum);
	}
}