import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long N = sc.nextLong();
		Long total  = 0L;
		for(int i = 1; i <= N; ++i){
	            if(i % 3 == 0 && i % 5 == 0){
	            	continue;
	            }else if(i % 3 == 0){
	                continue;
	            }else if(i % 5 == 0){
	            	continue;
	            }else{
	                total += i;
	            }
	     }
		System.out.println(total);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long N = sc.nextLong();
		Long total  = 0L;
		for(int i = 1; i <= N; ++i){
	            if(i % 3 == 0 && i % 5 == 0){
	            	continue;
	            }else if(i % 3 == 0){
	                continue;
	            }else if(i % 5 == 0){
	            	continue;
	            }else{
	                total += i;
	            }
	     }
		System.out.println(total);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long N = sc.nextLong();
		Long total  = 0L;
		for(int i = 1; i <= N; ++i){
	            if(i % 3 == 0 && i % 5 == 0){
	            	continue;
	            }else if(i % 3 == 0){
	                continue;
	            }else if(i % 5 == 0){
	            	continue;
	            }else{
	                total += i;
	            }
	     }
		System.out.println(total);
	} main {
		Scanner sc = new Scanner(System.in);
		Long N = sc.nextLong();
		Long total  = 0L;
		for(int i = 1; i <= N; ++i){
	            if(i % 3 == 0 && i % 5 == 0){
	            	continue;
	            }else if(i % 3 == 0){
	                continue;
	            }else if(i % 5 == 0){
	            	continue;
	            }else{
	                total += i;
	            }
	     }
		System.out.println(total);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Long N = sc.nextLong(); N sc.nextLong() sc.nextLong sc Long total  = 0L; total 0L for(int i = 1; i <= N; ++i){
	            if(i % 3 == 0 && i % 5 == 0){
	            	continue;
	            }else if(i % 3 == 0){
	                continue;
	            }else if(i % 5 == 0){
	            	continue;
	            }else{
	                total += i;
	            }
	     } int i = 1; int i = 1; i 1 i <= N i N ++i ++i i {
	            if(i % 3 == 0 && i % 5 == 0){
	            	continue;
	            }else if(i % 3 == 0){
	                continue;
	            }else if(i % 5 == 0){
	            	continue;
	            }else{
	                total += i;
	            }
	     } {
	            if(i % 3 == 0 && i % 5 == 0){
	            	continue;
	            }else if(i % 3 == 0){
	                continue;
	            }else if(i % 5 == 0){
	            	continue;
	            }else{
	                total += i;
	            }
	     } if(i % 3 == 0 && i % 5 == 0){
	            	continue;
	            }else if(i % 3 == 0){
	                continue;
	            }else if(i % 5 == 0){
	            	continue;
	            }else{
	                total += 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; if(i % 3 == 0){
	                continue;
	            }else if(i % 5 == 0){
	            	continue;
	            }else{
	                total += i;
	            } i % 3 == 0 i % 3 i 3 0 {
	                continue;
	            } continue; if(i % 5 == 0){
	            	continue;
	            }else{
	                total += i;
	            } i % 5 == 0 i % 5 i 5 0 {
	            	continue;
	            } continue; {
	                total += i;
	            } total += i total i System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long N = sc.nextLong();
		Long total  = 0L;
		for(int i = 1; i <= N; ++i){
	            if(i % 3 == 0 && i % 5 == 0){
	            	continue;
	            }else if(i % 3 == 0){
	                continue;
	            }else if(i % 5 == 0){
	            	continue;
	            }else{
	                total += i;
	            }
	     }
		System.out.println(total);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long N = sc.nextLong();
		Long total  = 0L;
		for(int i = 1; i <= N; ++i){
	            if(i % 3 == 0 && i % 5 == 0){
	            	continue;
	            }else if(i % 3 == 0){
	                continue;
	            }else if(i % 5 == 0){
	            	continue;
	            }else{
	                total += i;
	            }
	     }
		System.out.println(total);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long N = sc.nextLong();
		Long total  = 0L;
		for(int i = 1; i <= N; ++i){
	            if(i % 3 == 0 && i % 5 == 0){
	            	continue;
	            }else if(i % 3 == 0){
	                continue;
	            }else if(i % 5 == 0){
	            	continue;
	            }else{
	                total += i;
	            }
	     }
		System.out.println(total);
	}
}