	
	


import java.util.*; 
	public class Main {
	public static void main( String[] args) {			
					
					Scanner in = new Scanner(System.in);
					long a = in.nextInt();
					long s = 0;
					
					for(long i = 1;i<=a;i++) {
						if(i%3==0||i%5==0) {
							continue;
						}
						else {
							s = s+i;
						}
					}
					System.out.println(s);
					
			}} import java.util.*; util.* java public class Main {
	public static void main( String[] args) {			
					
					Scanner in = new Scanner(System.in);
					long a = in.nextInt();
					long s = 0;
					
					for(long i = 1;i<=a;i++) {
						if(i%3==0||i%5==0) {
							continue;
						}
						else {
							s = s+i;
						}
					}
					System.out.println(s);
					
			}} Main public static void main( String[] args) {			
					
					Scanner in = new Scanner(System.in);
					long a = in.nextInt();
					long s = 0;
					
					for(long i = 1;i<=a;i++) {
						if(i%3==0||i%5==0) {
							continue;
						}
						else {
							s = s+i;
						}
					}
					System.out.println(s);
					
			} main {			
					
					Scanner in = new Scanner(System.in);
					long a = in.nextInt();
					long s = 0;
					
					for(long i = 1;i<=a;i++) {
						if(i%3==0||i%5==0) {
							continue;
						}
						else {
							s = s+i;
						}
					}
					System.out.println(s);
					
			} Scanner in = new Scanner(System.in); in new Scanner(System.in) long a = in.nextInt(); a in.nextInt() in.nextInt in long s = 0; s 0 for(long i = 1;i<=a;i++) {
						if(i%3==0||i%5==0) {
							continue;
						}
						else {
							s = s+i;
						}
					} long i = 1; long i = 1; i 1 i<=a i a i++ i++ i {
						if(i%3==0||i%5==0) {
							continue;
						}
						else {
							s = s+i;
						}
					} {
						if(i%3==0||i%5==0) {
							continue;
						}
						else {
							s = s+i;
						}
					} if(i%3==0||i%5==0) {
							continue;
						}
						else {
							s = s+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; {
							s = s+i;
						} s = s+i s s+i s i System.out.println(s) System.out.println System.out System System.out s String[] args args public class Main {
	public static void main( String[] args) {			
					
					Scanner in = new Scanner(System.in);
					long a = in.nextInt();
					long s = 0;
					
					for(long i = 1;i<=a;i++) {
						if(i%3==0||i%5==0) {
							continue;
						}
						else {
							s = s+i;
						}
					}
					System.out.println(s);
					
			}} public class Main {
	public static void main( String[] args) {			
					
					Scanner in = new Scanner(System.in);
					long a = in.nextInt();
					long s = 0;
					
					for(long i = 1;i<=a;i++) {
						if(i%3==0||i%5==0) {
							continue;
						}
						else {
							s = s+i;
						}
					}
					System.out.println(s);
					
			}} Main
	
	


import java.util.*; 
	public class Main {
	public static void main( String[] args) {			
					
					Scanner in = new Scanner(System.in);
					long a = in.nextInt();
					long s = 0;
					
					for(long i = 1;i<=a;i++) {
						if(i%3==0||i%5==0) {
							continue;
						}
						else {
							s = s+i;
						}
					}
					System.out.println(s);
					
			}}