import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line = reader.readLine();
			int n = Integer.parseInt(line);
			long ans = 0;
			int[] a = new int[n];
			for(int i = 0; i < n; i++){
				a[i] = i + 1;
				if((a[i] % 3 != 0) && (a[i] % 5 != 0)){
					ans += a[i];
				}
			}
			System.out.println(ans);
		} catch(IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println(e);
		}
	}
} import java.io.*; io.* java class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line = reader.readLine();
			int n = Integer.parseInt(line);
			long ans = 0;
			int[] a = new int[n];
			for(int i = 0; i < n; i++){
				a[i] = i + 1;
				if((a[i] % 3 != 0) && (a[i] % 5 != 0)){
					ans += a[i];
				}
			}
			System.out.println(ans);
		} catch(IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println(e);
		}
	}
} Main public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line = reader.readLine();
			int n = Integer.parseInt(line);
			long ans = 0;
			int[] a = new int[n];
			for(int i = 0; i < n; i++){
				a[i] = i + 1;
				if((a[i] % 3 != 0) && (a[i] % 5 != 0)){
					ans += a[i];
				}
			}
			System.out.println(ans);
		} catch(IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println(e);
		}
	} main {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line = reader.readLine();
			int n = Integer.parseInt(line);
			long ans = 0;
			int[] a = new int[n];
			for(int i = 0; i < n; i++){
				a[i] = i + 1;
				if((a[i] % 3 != 0) && (a[i] % 5 != 0)){
					ans += a[i];
				}
			}
			System.out.println(ans);
		} catch(IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println(e);
		}
	} BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) try {
			String line = reader.readLine();
			int n = Integer.parseInt(line);
			long ans = 0;
			int[] a = new int[n];
			for(int i = 0; i < n; i++){
				a[i] = i + 1;
				if((a[i] % 3 != 0) && (a[i] % 5 != 0)){
					ans += a[i];
				}
			}
			System.out.println(ans);
		} catch(IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println(e);
		} catch(IOException e) {
			System.out.println(e);
		} IOException e {
			System.out.println(e);
		} System.out.println(e) System.out.println System.out System System.out e catch(NumberFormatException e) {
			System.out.println(e);
		} NumberFormatException e {
			System.out.println(e);
		} System.out.println(e) System.out.println System.out System System.out e {
			String line = reader.readLine();
			int n = Integer.parseInt(line);
			long ans = 0;
			int[] a = new int[n];
			for(int i = 0; i < n; i++){
				a[i] = i + 1;
				if((a[i] % 3 != 0) && (a[i] % 5 != 0)){
					ans += a[i];
				}
			}
			System.out.println(ans);
		} String line = reader.readLine(); line reader.readLine() reader.readLine reader int n = Integer.parseInt(line); n Integer.parseInt(line) Integer.parseInt Integer line long ans = 0; ans 0 int[] a = new int[n]; a new int[n] n for(int i = 0; i < n; i++){
				a[i] = i + 1;
				if((a[i] % 3 != 0) && (a[i] % 5 != 0)){
					ans += a[i];
				}
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				a[i] = i + 1;
				if((a[i] % 3 != 0) && (a[i] % 5 != 0)){
					ans += a[i];
				}
			} {
				a[i] = i + 1;
				if((a[i] % 3 != 0) && (a[i] % 5 != 0)){
					ans += a[i];
				}
			} a[i] = i + 1 a[i] a i i + 1 i 1 if((a[i] % 3 != 0) && (a[i] % 5 != 0)){
					ans += a[i];
				} (a[i] % 3 != 0) && (a[i] % 5 != 0) (a[i] % 3 != 0) a[i] % 3 a[i] a i 3 0 (a[i] % 5 != 0) a[i] % 5 a[i] a i 5 0 {
					ans += a[i];
				} ans += a[i] ans a[i] a i System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line = reader.readLine();
			int n = Integer.parseInt(line);
			long ans = 0;
			int[] a = new int[n];
			for(int i = 0; i < n; i++){
				a[i] = i + 1;
				if((a[i] % 3 != 0) && (a[i] % 5 != 0)){
					ans += a[i];
				}
			}
			System.out.println(ans);
		} catch(IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println(e);
		}
	}
}