import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		long n = sc.nextLong();

		long f = 0;
		for ( long i=1; i<=n; i++ ) {
			if ( i%3==0 || i%5==0 ) {
				continue;
			} else {
				f = f + i;
			}
		}
		System.out.println(f);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		long n = sc.nextLong();

		long f = 0;
		for ( long i=1; i<=n; i++ ) {
			if ( i%3==0 || i%5==0 ) {
				continue;
			} else {
				f = f + i;
			}
		}
		System.out.println(f);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		long n = sc.nextLong();

		long f = 0;
		for ( long i=1; i<=n; i++ ) {
			if ( i%3==0 || i%5==0 ) {
				continue;
			} else {
				f = f + i;
			}
		}
		System.out.println(f);
	} main {
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		long n = sc.nextLong();

		long f = 0;
		for ( long i=1; i<=n; i++ ) {
			if ( i%3==0 || i%5==0 ) {
				continue;
			} else {
				f = f + i;
			}
		}
		System.out.println(f);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long n = sc.nextLong(); n sc.nextLong() sc.nextLong sc long f = 0; f 0 for ( long i=1; i<=n; i++ ) {
			if ( i%3==0 || i%5==0 ) {
				continue;
			} else {
				f = f + i;
			}
		} long i=1; long i=1; i 1 i<=n i n i++ i++ i {
			if ( i%3==0 || i%5==0 ) {
				continue;
			} else {
				f = f + i;
			}
		} {
			if ( i%3==0 || i%5==0 ) {
				continue;
			} else {
				f = f + i;
			}
		} if ( i%3==0 || i%5==0 ) {
				continue;
			} else {
				f = f + i;
			} i%3==0 || i%5==0 i%3==0 i%3 i 3 0 i%5==0 i%5 i 5 0 {
				continue;
			} continue; {
				f = f + i;
			} f = f + i f f + i f i System.out.println(f) System.out.println System.out System System.out f String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		long n = sc.nextLong();

		long f = 0;
		for ( long i=1; i<=n; i++ ) {
			if ( i%3==0 || i%5==0 ) {
				continue;
			} else {
				f = f + i;
			}
		}
		System.out.println(f);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		long n = sc.nextLong();

		long f = 0;
		for ( long i=1; i<=n; i++ ) {
			if ( i%3==0 || i%5==0 ) {
				continue;
			} else {
				f = f + i;
			}
		}
		System.out.println(f);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		long n = sc.nextLong();

		long f = 0;
		for ( long i=1; i<=n; i++ ) {
			if ( i%3==0 || i%5==0 ) {
				continue;
			} else {
				f = f + i;
			}
		}
		System.out.println(f);
	}
}
